#include <dali/graphics-api/graphics-controller.h>
#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
{
std::ostream& operator<<(std::ostream& o, Graphics::SamplerMipmapMode mipmapMode);
std::ostream& operator<<(std::ostream& o, const Graphics::SamplerCreateInfo& createInfo);
+template<typename T>
+T* Uncast(const Graphics::CommandBuffer* object)
+{
+ return const_cast<T*>(static_cast<const T*>(object));
+}
+
+template<typename T>
+T* Uncast(const Graphics::Texture* object)
+{
+ return const_cast<T*>(static_cast<const T*>(object));
+}
+
+template<typename T>
+T* Uncast(const Graphics::Sampler* object)
+{
+ return const_cast<T*>(static_cast<const T*>(object));
+}
+
+template<typename T>
+T* Uncast(const Graphics::Buffer* object)
+{
+ return const_cast<T*>(static_cast<const T*>(object));
+}
+
+template<typename T>
+T* Uncast(const Graphics::Shader* object)
+{
+ return const_cast<T*>(static_cast<const T*>(object));
+}
+
+template<typename T>
+T* Uncast(const Graphics::Framebuffer* object)
+{
+ return const_cast<T*>(static_cast<const T*>(object));
+}
+
+template<typename T>
+T* Uncast(const Graphics::Pipeline* object)
+{
+ return const_cast<T*>(static_cast<const T*>(object));
+}
+
+template<typename T>
+T* Uncast(const Graphics::RenderTarget* object)
+{
+ return const_cast<T*>(static_cast<const T*>(object));
+}
+
+template<typename T>
+T* Uncast(const Graphics::SyncObject* object)
+{
+ return const_cast<T*>(static_cast<const T*>(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
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
*
*/
void UpdateTextures(const std::vector<Graphics::TextureUpdateInfo>& updateInfoList,
- const std::vector<Graphics::TextureUpdateSourceInfo>& sourceList) override
- {
- }
+ const std::vector<Graphics::TextureUpdateSourceInfo>& 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
* @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 {};
- }
+ Graphics::UniquePtr<Graphics::Buffer> CreateBuffer(const Graphics::BufferCreateInfo& bufferCreateInfo, Graphics::UniquePtr<Graphics::Buffer>&& oldBuffer) override;
/**
* @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 {};
- }
+ Graphics::UniquePtr<Graphics::CommandBuffer> CreateCommandBuffer(const Graphics::CommandBufferCreateInfo& commandBufferCreateInfo, Graphics::UniquePtr<Graphics::CommandBuffer>&& oldCommandBuffer) override;
/**
* @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 {};
- }
+ Graphics::UniquePtr<Graphics::RenderPass> CreateRenderPass(const Graphics::RenderPassCreateInfo& renderPassCreateInfo, Graphics::UniquePtr<Graphics::RenderPass>&& oldRenderPass) override;
/**
* @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 {};
- }
+ Graphics::UniquePtr<Graphics::Texture> CreateTexture(const Graphics::TextureCreateInfo& textureCreateInfo, Graphics::UniquePtr<Graphics::Texture>&& oldTexture) override;
/**
* @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 {};
- }
+ Graphics::UniquePtr<Graphics::Framebuffer> CreateFramebuffer(const Graphics::FramebufferCreateInfo& framebufferCreateInfo, Graphics::UniquePtr<Graphics::Framebuffer>&& oldFramebuffer) override;
/**
* @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 {};
- }
+ Graphics::UniquePtr<Graphics::Pipeline> CreatePipeline(const Graphics::PipelineCreateInfo& pipelineCreateInfo, Graphics::UniquePtr<Graphics::Pipeline>&& oldPipeline) override;
+
+ /**
+ * @brief Creates new Program object
+ *
+ * @param[in] programCreateInfo The valid ProgramCreateInfo structure
+ * @return pointer to the Program object
+ */
+ Graphics::UniquePtr<Graphics::Program> CreateProgram(const Graphics::ProgramCreateInfo& programCreateInfo, Graphics::UniquePtr<Graphics::Program>&& oldProgram) override;
/**
* @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 {};
- }
+ Graphics::UniquePtr<Graphics::Shader> CreateShader(const Graphics::ShaderCreateInfo& shaderCreateInfo, Graphics::UniquePtr<Graphics::Shader>&& oldShader) override;
/**
* @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 {};
- }
+ Graphics::UniquePtr<Graphics::Sampler> CreateSampler(const Graphics::SamplerCreateInfo& samplerCreateInfo, Graphics::UniquePtr<Graphics::Sampler>&& oldSampler) override;
/**
* @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 {};
- }
+ Graphics::UniquePtr<Graphics::RenderTarget> CreateRenderTarget(const Graphics::RenderTargetCreateInfo& renderTargetCreateInfo, Graphics::UniquePtr<Graphics::RenderTarget>&& oldRenderTarget) override;
+
+ /**
+ * @brief Creates new sync object
+ * Could add timeout etc to createinfo... but nah.
+ *
+ * @return pointer to the SyncObject
+ */
+ Graphics::UniquePtr<Graphics::SyncObject> CreateSyncObject(const Graphics::SyncObjectCreateInfo& syncObjectCreateInfo,
+ Graphics::UniquePtr<Graphics::SyncObject>&& 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<Graphics::Memory> MapBufferRange(const Graphics::MapBufferInfo& mapInfo) override
- {
- return {};
- }
+ Graphics::UniquePtr<Graphics::Memory> MapBufferRange(const Graphics::MapBufferInfo& mapInfo) override;
/**
* @brief Maps memory associated with the texture.
*
* @return Valid Memory object or nullptr on error
*/
- std::unique_ptr<Graphics::Memory> MapTextureRange(const Graphics::MapTextureInfo& mapInfo) override
- {
- return {};
- }
+ Graphics::UniquePtr<Graphics::Memory> MapTextureRange(const Graphics::MapTextureInfo& mapInfo) override;
/**
* @brief Unmaps memory and discards Memory object
*
* @param[in] memory Valid and previously mapped Memory object
*/
- void UnmapMemory(std::unique_ptr<Graphics::Memory> memory) override
- {
- }
+ void UnmapMemory(Graphics::UniquePtr<Graphics::Memory> memory) override;
/**
* @brief Returns memory requirements of the Texture object.
*
* @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.
*
* @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
*
* @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.
*
* @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<UniformData>& 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<Graphics::SubmitInfo> mSubmitStack;
- TestGlAbstraction mGlAbstraction;
- TestGlSyncAbstraction mGlSyncAbstraction;
+ TestGlAbstraction mGl;
+ TestGraphicsSyncImplementation mGraphicsSyncImpl;
TestGlContextHelperAbstraction mGlContextHelperAbstraction;
bool isDiscardQueueEmptyResult{true};
bool isDrawOnResumeRequiredResult{true};
+
+ Property::Array mVertexFormats;
+
+ struct ProgramCache
+ {
+ std::map<Graphics::PipelineStage, std::vector<uint8_t>> shaders;
+ TestGraphicsProgramImpl* programImpl;
+ };
+ std::vector<ProgramCache> mProgramCache;
+
+ struct PipelineCache
+ {
+ };
+
+ std::vector<UniformData> mCustomUniforms;
};
} // namespace Dali