X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Ftest-graphics-controller.h;h=cabc414740955c4532831101a6ae7649681235e0;hp=803678e218190e76577d294ef015110ec9918cac;hb=HEAD;hpb=e3c6384a98d24c40ac6fd04f4bd091035cc9df6a 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 803678e..6066f67 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 @@ -2,7 +2,7 @@ #define TEST_GRAPHICS_CONTROLLER_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -18,11 +18,12 @@ */ #include +#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 { @@ -36,6 +37,60 @@ 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: @@ -48,19 +103,19 @@ public: mGl.Initialize(); } - Integration::GlAbstraction& GetGlAbstraction() override + Integration::GlAbstraction& GetGlAbstraction() { return mGl; } - Integration::GlSyncAbstraction& GetGlSyncAbstraction() override + Integration::GraphicsConfig& GetGraphicsConfig() { - return mGlSyncAbstraction; + return mGl; } - Integration::GlContextHelperAbstraction& GetGlContextHelperAbstraction() override + TestGraphicsSyncImplementation& GetGraphicsSyncImpl() { - return mGlContextHelperAbstraction; + return mGraphicsSyncImpl; } void SubmitCommandBuffers(const Graphics::SubmitInfo& submitInfo) override; @@ -113,6 +168,12 @@ public: 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; @@ -146,6 +207,8 @@ public: */ Graphics::UniquePtr CreateBuffer(const Graphics::BufferCreateInfo& bufferCreateInfo, Graphics::UniquePtr&& oldBuffer) override; + void DiscardBuffer(TestGraphicsBuffer* buffer); + /** * @brief Creates new CommandBuffer object * @@ -219,11 +282,20 @@ public: 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 */ Graphics::UniquePtr MapBufferRange(const Graphics::MapBufferInfo& mapInfo) override; @@ -284,7 +356,7 @@ public: * * @return Returns the TextureProperties object */ - const Graphics::TextureProperties& GetTextureProperties(const Graphics::Texture& texture) override; + Graphics::TextureProperties GetTextureProperties(const Graphics::Texture& texture) override; /** * @brief Returns the reflection of the given program @@ -303,7 +375,63 @@ public: */ bool PipelineEquals(const Graphics::Pipeline& pipeline0, const Graphics::Pipeline& pipeline1) const override; + /** + * @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; + +public: // ResourceId relative API. + /** + * @brief Create Graphics::Texture as resourceId. + * The ownership of Graphics::Texture will be hold on this controller. + * @note If some Graphics::Texture already created before, assert. + * @post DiscardTextureFromResourceId() or ReleaseTextureFromResourceId() should be called when we don't use resourceId texture anymore. + * + * @param[in] resourceId The unique id of resouces. + * @return Pointer of Graphics::Texture, or nullptr if we fail to create. + */ + Graphics::Texture* CreateTextureByResourceId(uint32_t resourceId, const Graphics::TextureCreateInfo& createInfo) override; + + /** + * @brief Discard Graphics::Texture as resourceId. + * + * @param[in] resourceId The unique id of resouces. + */ + void DiscardTextureFromResourceId(uint32_t resourceId) override; + + /** + * @brief Get the Graphics::Texture as resourceId. + * + * @param[in] resourceId The unique id of resouces. + * @return Pointer of Graphics::Texture, or nullptr if there is no valid objects. + */ + Graphics::Texture* GetTextureFromResourceId(uint32_t resourceId) override; + + /** + * @brief Get the ownership of Graphics::Texture as resourceId. + * + * @param[in] resourceId The unique id of resouces. + * @return Pointer of Graphics::Texture. + */ + Graphics::UniquePtr ReleaseTextureFromResourceId(uint32_t resourceId) override; + public: // Test Functions + void SetAutoAttrCreation(bool v) + { + mAutoAttrCreation = v; + } + bool AutoAttrCreation() + { + return mAutoAttrCreation; + } + void SetVertexFormats(Property::Array& vfs) { mVertexFormats = vfs; @@ -314,35 +442,32 @@ public: // Test Functions mCustomUniforms = customUniforms; } + void AddCustomUniformBlock(const TestGraphicsReflection::TestUniformBlockInfo& blockInfo) + { + mCustomUniformBlocks.push_back(blockInfo); + } + void ClearSubmitStack() { 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 mGl; - TestGlSyncAbstraction mGlSyncAbstraction; - TestGlContextHelperAbstraction mGlContextHelperAbstraction; - - bool isDiscardQueueEmptyResult{true}; - bool isDrawOnResumeRequiredResult{true}; + TestGraphicsSyncImplementation mGraphicsSyncImpl; + bool isDiscardQueueEmptyResult{true}; + bool isDrawOnResumeRequiredResult{true}; + bool mAutoAttrCreation{true}; Property::Array mVertexFormats; struct ProgramCache @@ -352,7 +477,16 @@ public: }; std::vector mProgramCache; - std::vector mCustomUniforms; + std::vector mAllocatedBuffers; + + std::unordered_map> mTextureUploadBindMapper; + + struct PipelineCache + { + }; + + std::vector mCustomUniforms; + std::vector mCustomUniformBlocks; }; } // namespace Dali