Dummy graphics controller 75/252975/2
authoradam.b <adam.b@samsung.com>
Thu, 21 Jan 2021 12:43:29 +0000 (12:43 +0000)
committerAdam Bialogonski <adam.b@samsung.com>
Wed, 3 Feb 2021 15:19:38 +0000 (15:19 +0000)
Change-Id: I23618deab26e4e8f1ef59bd09d86f8f423426593

automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-controller.h
dali/internal/graphics/gles/egl-graphics-controller.h

index f5ab764..120f984 100644 (file)
 
 namespace Dali
 {
+std::ostream& operator<<(std::ostream& o, const Graphics::BufferCreateInfo& bufferCreateInfo);
+std::ostream& operator<<(std::ostream& o, const Graphics::CommandBufferCreateInfo& commandBufferCreateInfo);
+std::ostream& operator<<(std::ostream& o, const Graphics::TextureType& textureType);
+std::ostream& operator<<(std::ostream& o, const Graphics::Extent2D extent);
+std::ostream& operator<<(std::ostream& o, const Graphics::TextureCreateInfo& createInfo);
+std::ostream& operator<<(std::ostream& o, Graphics::SamplerAddressMode addressMode);
+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);
+
 class TestGraphicsController : public Dali::Graphics::Controller
 {
 public:
-  TestGraphicsController()          = default;
+  TestGraphicsController()
+  {
+  }
+
   virtual ~TestGraphicsController() = default;
 
   void Initialize()
@@ -50,10 +63,301 @@ public:
     return mGlContextHelperAbstraction;
   }
 
-private:
+  void SubmitCommandBuffers(const Graphics::SubmitInfo& submitInfo) override
+  {
+  }
+
+  /**
+   * @brief Presents render target
+   * @param renderTarget render target to present
+   */
+  void PresentRenderTarget(Graphics::RenderTarget* renderTarget) override
+  {
+  }
+
+  /**
+   * @brief Waits until the GPU is idle
+   */
+  void WaitIdle() override
+  {
+  }
+
+  /**
+   * @brief Lifecycle pause event
+   */
+  void Pause() override
+  {
+  }
+
+  /**
+   * @brief Lifecycle resume event
+   */
+  void Resume() override
+  {
+  }
+
+  /**
+   * @brief Executes batch update of textures
+   *
+   * This function may perform full or partial update of many textures.
+   * The data source may come from:
+   * - CPU memory (client side)
+   * - GPU memory (another Texture or Buffer)
+   *
+   * UpdateTextures() is the only way to update unmappable Texture objects.
+   * It is recommended to batch updates as it may help with optimizing
+   * memory transfers based on dependencies.
+   *
+   */
+  void UpdateTextures(const std::vector<Graphics::TextureUpdateInfo>&       updateInfoList,
+                      const std::vector<Graphics::TextureUpdateSourceInfo>& sourceList) override
+  {
+  }
+
+  /**
+   * TBD: do we need those functions in the new implementation?
+   */
+  bool EnableDepthStencilBuffer(bool enableDepth, bool enableStencil) override
+  {
+    return {};
+  }
+
+  void RunGarbageCollector(size_t numberOfDiscardedRenderers) override
+  {
+  }
+
+  void DiscardUnusedResources() override
+  {
+  }
+
+  bool IsDiscardQueueEmpty() override
+  {
+    return {};
+  }
+
+  /**
+   * @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 {};
+  }
+
+  /**
+   * @brief Creates new Buffer object
+   *
+   * The Buffer object is created with underlying memory. The Buffer
+   * specification is immutable. Based on the BufferCreateInfo::usage,
+   * the memory may be client-side mappable or not.
+   *
+   * The old buffer may be passed as BufferCreateInfo::oldbuffer, however,
+   * it's up to the implementation whether the object will be reused or
+   * discarded and replaced by the new one.
+   *
+   * @param[in] bufferCreateInfo The valid BufferCreateInfo structure
+   * @return pointer to the Buffer object
+   */
+  std::unique_ptr<Graphics::Buffer> CreateBuffer(const Graphics::BufferCreateInfo& bufferCreateInfo, std::unique_ptr<Graphics::Buffer>&& oldBuffer) override
+  {
+    return {};
+  }
+
+  /**
+   * @brief Creates new CommandBuffer object
+   *
+   * @param[in] bufferCreateInfo The valid BufferCreateInfo structure
+   * @return pointer to the CommandBuffer object
+   */
+  std::unique_ptr<Graphics::CommandBuffer> CreateCommandBuffer(const Graphics::CommandBufferCreateInfo& commandBufferCreateInfo, std::unique_ptr<Graphics::CommandBuffer>&& oldCommandBuffer) override
+  {
+    return {};
+  }
+
+  /**
+   * @brief Creates new RenderPass object
+   *
+   * @param[in] renderPassCreateInfo The valid RenderPassCreateInfo structure
+   * @return pointer to the RenderPass object
+   */
+  std::unique_ptr<Graphics::RenderPass> CreateRenderPass(const Graphics::RenderPassCreateInfo& renderPassCreateInfo, std::unique_ptr<Graphics::RenderPass>&& oldRenderPass) override
+  {
+    return {};
+  }
+
+  /**
+   * @brief Creates new Texture object
+   *
+   * @param[in] textureCreateInfo The valid TextureCreateInfo structure
+   * @return pointer to the TextureCreateInfo object
+   */
+  std::unique_ptr<Graphics::Texture> CreateTexture(const Graphics::TextureCreateInfo& textureCreateInfo, std::unique_ptr<Graphics::Texture>&& oldTexture) override
+  {
+    return {};
+  }
+
+  /**
+   * @brief Creates new Framebuffer object
+   *
+   * @param[in] framebufferCreateInfo The valid FramebufferCreateInfo structure
+   * @return pointer to the Framebuffer object
+   */
+  std::unique_ptr<Graphics::Framebuffer> CreateFramebuffer(const Graphics::FramebufferCreateInfo& framebufferCreateInfo, std::unique_ptr<Graphics::Framebuffer>&& oldFramebuffer) override
+  {
+    return {};
+  }
+
+  /**
+   * @brief Creates new Pipeline object
+   *
+   * @param[in] pipelineCreateInfo The valid PipelineCreateInfo structure
+   * @return pointer to the Pipeline object
+   */
+  std::unique_ptr<Graphics::Pipeline> CreatePipeline(const Graphics::PipelineCreateInfo& pipelineCreateInfo, std::unique_ptr<Graphics::Pipeline>&& oldPipeline) override
+  {
+    return {};
+  }
+
+  /**
+   * @brief Creates new Shader object
+   *
+   * @param[in] shaderCreateInfo The valid ShaderCreateInfo structure
+   * @return pointer to the Shader object
+   */
+  std::unique_ptr<Graphics::Shader> CreateShader(const Graphics::ShaderCreateInfo& shaderCreateInfo, std::unique_ptr<Graphics::Shader>&& oldShader) override
+  {
+    return {};
+  }
+
+  /**
+   * @brief Creates new Sampler object
+   *
+   * @param[in] samplerCreateInfo The valid SamplerCreateInfo structure
+   * @return pointer to the Sampler object
+   */
+  std::unique_ptr<Graphics::Sampler> CreateSampler(const Graphics::SamplerCreateInfo& samplerCreateInfo, std::unique_ptr<Graphics::Sampler>&& oldSampler) override
+  {
+    return {};
+  }
+
+  /**
+   * @brief Creates new RenderTarget object
+   *
+   * @param[in] renderTargetCreateInfo The valid RenderTargetCreateInfo structure
+   * @return pointer to the RenderTarget object
+   */
+  std::unique_ptr<Graphics::RenderTarget> CreateRenderTarget(const Graphics::RenderTargetCreateInfo& renderTargetCreateInfo, std::unique_ptr<Graphics::RenderTarget>&& oldRenderTarget) override
+  {
+    return {};
+  }
+
+  /**
+   * @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
+   */
+  std::unique_ptr<Graphics::Memory> MapBufferRange(const Graphics::MapBufferInfo& mapInfo) override
+  {
+    return {};
+  }
+
+  /**
+   * @brief Maps memory associated with the texture.
+   *
+   * Only Texture objects that are backed with linear memory (staging memory) can be mapped.
+   * Example:
+   * 1) GLES implementation may create PBO object as staging memory and couple it
+   * with the texture. Texture can be mapped and the memory can be read/write on demand.
+   *
+   * 2) Vulkan implementation may allocate DeviceMemory and use linear layout.
+   *
+   * @param[in] mapInfo Filled details of mapped resource
+   *
+   * @return Valid Memory object or nullptr on error
+   */
+  std::unique_ptr<Graphics::Memory> MapTextureRange(const Graphics::MapTextureInfo& mapInfo) override
+  {
+    return {};
+  }
+
+  /**
+   * @brief Unmaps memory and discards Memory object
+   *
+   * This function automatically removes lock if Memory has been
+   * previously locked.
+   *
+   * @param[in] memory Valid and previously mapped Memory object
+   */
+  void UnmapMemory(std::unique_ptr<Graphics::Memory> memory) override
+  {
+  }
+
+  /**
+   * @brief Returns memory requirements of the Texture object.
+   *
+   * Call this function whenever it's necessary to know how much memory
+   * is needed to store all the texture data and what memory alignment
+   * the data should follow.
+   *
+   * @return Returns memory requirements of Texture
+   */
+  Graphics::MemoryRequirements GetTextureMemoryRequirements(Graphics::Texture& texture) const override
+  {
+    return {};
+  }
+
+  /**
+   * @brief Returns memory requirements of the Buffer object.
+   *
+   * Call this function whenever it's necessary to know how much memory
+   * is needed to store all the buffer data and what memory alignment
+   * the data should follow.
+   *
+   * @return Returns memory requirements of Buffer
+   */
+  Graphics::MemoryRequirements GetBufferMemoryRequirements(Graphics::Buffer& buffer) const override
+  {
+    return {};
+  }
+
+  /**
+   * @brief Returns specification of the Texture object
+   *
+   * Function obtains specification of the Texture object. It may retrieve
+   * implementation dependent details like ie. whether the texture is
+   * emulated (for example, RGB emulated on RGBA), compressed etc.
+   *
+   * @return Returns the TextureProperties object
+   */
+  const Graphics::TextureProperties& GetTextureProperties(const Graphics::Texture& texture) override
+  {
+    static Graphics::TextureProperties properties{};
+    return properties;
+  }
+
+  /**
+   * @brief Tests whether two Pipelines are the same.
+   *
+   * On the higher level, this function may help wit creating pipeline cache.
+   *
+   * @return true if pipeline objects match
+   */
+  bool PipelineEquals(const Graphics::Pipeline& pipeline0, const Graphics::Pipeline& pipeline1) const override
+  {
+    return {};
+  }
+
+public:
+
   TestGlAbstraction              mGlAbstraction;
   TestGlSyncAbstraction          mGlSyncAbstraction;
   TestGlContextHelperAbstraction mGlContextHelperAbstraction;
+
+  bool isDiscardQueueEmptyResult{true};
+  bool isDrawOnResumeRequiredResult{true};
 };
 
 } // namespace Dali
index 5942d76..1e9125c 100644 (file)
@@ -35,12 +35,12 @@ namespace Graphics
  *
  * Temporarily holds the old GL abstractions whilst dali-core is migrated to the new API.
  */
-class EglGraphicsController : public Graphics::Controller
+DALI_IMPORT_API class EglGraphicsController : public Graphics::Controller
 {
 public:
   EglGraphicsController() = default;
 
-  virtual ~EglGraphicsController() = default;
+  ~EglGraphicsController() override = default;
 
   /**
    * Initialize the GLES abstraction. This can be called from the main thread.
@@ -59,6 +59,220 @@ public:
   Integration::GlSyncAbstraction&          GetGlSyncAbstraction() override;
   Integration::GlContextHelperAbstraction& GetGlContextHelperAbstraction() override;
 
+  /**
+   * @copydoc Dali::Graphics::SubmitCommandBuffers()
+   */
+  void SubmitCommandBuffers(const SubmitInfo& submitInfo) override
+  {
+  }
+
+  /**
+   * @copydoc Dali::Graphics::PresentRenderTarget()
+   */
+  void PresentRenderTarget(RenderTarget* renderTarget) override
+  {
+  }
+
+  /**
+   * @copydoc Dali::Graphics::WaitIdle()
+   */
+  void WaitIdle() override
+  {
+  }
+
+  /**
+   * @copydoc Dali::Graphics::Pause()
+   */
+  void Pause() override
+  {
+  }
+
+  /**
+   * @copydoc Dali::Graphics::Resume()
+   */
+  void Resume() override
+  {
+  }
+
+  /**
+   * @copydoc Dali::Graphics::UpdateTextures()
+   */
+  void UpdateTextures(const std::vector<TextureUpdateInfo>&       updateInfoList,
+                      const std::vector<TextureUpdateSourceInfo>& sourceList) override
+  {
+  }
+
+  /**
+   * @copydoc Dali::Graphics::EnableDepthStencilBuffer()
+   */
+  bool EnableDepthStencilBuffer(bool enableDepth, bool enableStencil) override
+  {
+    return {};
+  }
+
+  /**
+   * @copydoc Dali::Graphics::RunGarbageCollector()
+   */
+  void RunGarbageCollector(size_t numberOfDiscardedRenderers) override
+  {
+  }
+
+  /**
+   * @copydoc Dali::Graphics::DiscardUnusedResources()
+   */
+  void DiscardUnusedResources() override
+  {
+  }
+
+  /**
+   * @copydoc Dali::Graphics::IsDiscardQueueEmpty()
+   */
+  bool IsDiscardQueueEmpty() override
+  {
+    return {};
+  }
+
+  /**
+   * @copydoc Dali::Graphics::IsDrawOnResumeRequired()
+   */
+  bool IsDrawOnResumeRequired() override
+  {
+    return {};
+  }
+
+  /**
+   * @copydoc Dali::Graphics::CreateBuffer()
+   */
+  std::unique_ptr<Buffer> CreateBuffer(const BufferCreateInfo& bufferCreateInfo, std::unique_ptr<Buffer>&& oldBuffer) override
+  {
+    return nullptr;
+  }
+
+  /**
+   * @copydoc Dali::Graphics::CreateCommandBuffer()
+   */
+  std::unique_ptr<CommandBuffer> CreateCommandBuffer(const CommandBufferCreateInfo& commandBufferCreateInfo, std::unique_ptr<CommandBuffer>&& oldCommandBuffer) override
+  {
+    return nullptr;
+  }
+
+  /**
+   * @copydoc Dali::Graphics::CreateRenderPass()
+   */
+  std::unique_ptr<RenderPass> CreateRenderPass(const RenderPassCreateInfo& renderPassCreateInfo, std::unique_ptr<RenderPass>&& oldRenderPass) override
+  {
+    return nullptr;
+  }
+
+  /**
+   * @copydoc Dali::Graphics::CreateTexture()
+   */
+  std::unique_ptr<Texture> CreateTexture(const TextureCreateInfo& textureCreateInfo, std::unique_ptr<Texture>&& oldTexture) override
+  {
+    return nullptr;
+  }
+
+  /**
+   * @copydoc Dali::Graphics::CreateFramebuffer()
+   */
+  std::unique_ptr<Framebuffer> CreateFramebuffer(const FramebufferCreateInfo& framebufferCreateInfo, std::unique_ptr<Framebuffer>&& oldFramebuffer) override
+  {
+    return nullptr;
+  }
+
+  /**
+   * @copydoc Dali::Graphics::CreatePipeline()
+   */
+  std::unique_ptr<Pipeline> CreatePipeline(const PipelineCreateInfo& pipelineCreateInfo, std::unique_ptr<Pipeline>&& oldPipeline) override
+  {
+    return nullptr;
+  }
+
+  /**
+   * @copydoc Dali::Graphics::CreateShader()
+   */
+  std::unique_ptr<Shader> CreateShader(const ShaderCreateInfo& shaderCreateInfo, std::unique_ptr<Shader>&& oldShader) override
+  {
+    return nullptr;
+  }
+
+  /**
+   * @copydoc Dali::Graphics::CreateSampler()
+   */
+  std::unique_ptr<Sampler> CreateSampler(const SamplerCreateInfo& samplerCreateInfo, std::unique_ptr<Sampler>&& oldSampler) override
+  {
+    return nullptr;
+  }
+
+  /**
+   * @copydoc Dali::Graphics::CreateRenderTarget()
+   */
+  std::unique_ptr<RenderTarget> CreateRenderTarget(const RenderTargetCreateInfo& renderTargetCreateInfo, std::unique_ptr<RenderTarget>&& oldRenderTarget) override
+  {
+    return nullptr;
+  }
+
+  /**
+   * @copydoc Dali::Graphics::MapBufferRange()
+   */
+  std::unique_ptr<Memory> MapBufferRange(const MapBufferInfo& mapInfo) override
+  {
+    return nullptr;
+  }
+
+  /**
+   * @copydoc Dali::Graphics::MapTextureRange()
+   */
+  std::unique_ptr<Memory> MapTextureRange(const MapTextureInfo& mapInfo) override
+  {
+    return nullptr;
+  }
+
+  /**
+   * @copydoc Dali::Graphics::UnmapMemory()
+   */
+  void UnmapMemory(std::unique_ptr<Memory> memory) override
+  {
+  }
+  /**
+   * @copydoc Dali::Graphics::GetTextureMemoryRequirements()
+   */
+  MemoryRequirements GetTextureMemoryRequirements(Texture& texture) const override
+  {
+    return {};
+  }
+
+  /**
+   * @copydoc Dali::Graphics::GetBufferMemoryRequirements()
+   */
+  MemoryRequirements GetBufferMemoryRequirements(Buffer& buffer) const override
+  {
+    return {};
+  }
+
+  /**
+   * @copydoc Dali::Graphics::GetTextureProperties()
+   */
+  const TextureProperties& GetTextureProperties(const Texture& texture) override
+  {
+    // for compiler not to moan
+    static TextureProperties dummy{};
+    return dummy;
+  }
+
+  /**
+   * @copydoc Dali::Graphics::PipelineEquals()
+   */
+  [[nodiscard]] bool PipelineEquals(const Pipeline& pipeline0, const Pipeline& pipeline1) const override
+  {
+    return {};
+  }
+
+  [[nodiscard]] Integration::GlAbstraction* GetGL() const
+  {
+    return mGlAbstraction;
+  }
+
 private:
   Integration::GlAbstraction*              mGlAbstraction{nullptr};
   Integration::GlSyncAbstraction*          mGlSyncAbstraction{nullptr};