dali-core
)
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${CAPI_LIB}_CFLAGS_OTHER} -O0 -ggdb --coverage -Wall -Werror -std=c++11 ")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${CAPI_LIB}_CFLAGS_OTHER} -O0 -ggdb --coverage -Wall -Werror -std=c++14 ")
FOREACH(directory ${${CAPI_LIB}_LIBRARY_DIRS})
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L${directory}")
ENDIF()
# Set up compiler flags and warnings
-#ADD_COMPILE_OPTIONS( -std=c++11 -ggdb )
-ADD_COMPILE_OPTIONS( -std=c++11 -gdwarf-4 )
+#ADD_COMPILE_OPTIONS( -std=c++14 -ggdb )
+ADD_COMPILE_OPTIONS( -std=c++14 -gdwarf-4 )
ADD_COMPILE_OPTIONS( -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast )
ADD_COMPILE_OPTIONS( -Werror -Wall -Wextra -Wno-unused-parameter -Wfloat-equal )
Version: ${apiversion}
Requires:
Libs: -L${libdir} -ldali-core
-Cflags: -I${includedir} -std=c++11
+Cflags: -I${includedir} -std=c++14
-# Copyright (c) 2017 Samsung Electronics Co., Ltd.
+# Copyright (c) 2018 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.
DALI_CFLAGS=-DPLATFORM_TIZEN
# Use C++ 11
-DALI_CFLAGS="$DALI_CFLAGS -std=c++11 -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast -Werror -Wall -Wextra -Wno-unused-parameter -Wfloat-equal"
+DALI_CFLAGS="$DALI_CFLAGS -std=c++14 -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast -Werror -Wall -Wextra -Wno-unused-parameter -Wfloat-equal"
AC_ARG_ENABLE(exportall,
[AC_HELP_STRING([--enable-exportall],
Version: ${apiversion}
Requires:
Libs: -L${libdir} -ldali-core-cxx03
-Cflags: -I${includedir} -std=c++11
+Cflags: -I${includedir} -std=c++14
Version: ${apiversion}
Requires:
Libs: -L${libdir} -ldali-core
-Cflags: -I${includedir} -std=c++11
+Cflags: -I${includedir} -std=c++14
--- /dev/null
+#ifndef DALI_GRAPHICS_API_BUFFER_H
+#define DALI_GRAPHICS_API_BUFFER_H
+
+/*
+ * Copyright (c) 2018 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+
+/**
+ * @brief Interface class for Buffer types in the graphics API.
+ */
+class Buffer
+{
+public:
+ /**
+ * @brief Usage of the buffer
+ */
+ enum class UsageHint
+ {
+ FRAME_CONSTANTS,
+ PRIMITIVE_UNIFORMS,
+ ATTRIBUTES,
+ INSTANCE,
+ INDEX_BUFFER,
+ };
+
+ // not copyable
+ Buffer(const Buffer&) = delete;
+ Buffer& operator=(const Buffer&) = delete;
+
+ virtual ~Buffer() = default;
+
+ // TODO: @todo GetHints
+ size_t GetSize() const;
+ void* GetData();
+
+protected:
+ // derived types should not be moved direcly to prevent slicing
+ Buffer(Buffer&&) = default;
+ Buffer& operator=(Buffer&&) = default;
+
+ /**
+ * Objects of this type should not directly.
+ */
+ Buffer() = default;
+};
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_BUFFER_H
#define DALI_GRAPHICS_API_CONTROLLER_H
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
*
*/
+// INTERNAL INCLUDES
#include <dali/graphics-api/graphics-api-accessor.h>
#include <dali/graphics-api/graphics-api-base-factory.h>
#include <dali/graphics-api/graphics-api-dynamic-buffer.h>
+#include <dali/graphics-api/graphics-api-frame.h>
#include <dali/graphics-api/graphics-api-framebuffer.h>
+#include <dali/graphics-api/graphics-api-generic-buffer.h>
+#include <dali/graphics-api/graphics-api-render-command.h>
#include <dali/graphics-api/graphics-api-sampler.h>
#include <dali/graphics-api/graphics-api-shader.h>
#include <dali/graphics-api/graphics-api-static-buffer.h>
+#include <dali/graphics-api/graphics-api-texture-factory.h>
#include <dali/graphics-api/graphics-api-texture-set.h>
#include <dali/graphics-api/graphics-api-texture.h>
-#include <dali/graphics-api/graphics-api-texture-factory.h>
+#include <dali/graphics-api/utility/utility-builder.h>
namespace Dali
{
{
namespace API
{
-
/**
* @brief Interface class for Manager types in the graphics API.
*/
/**
* @brief Create a new object
*/
- virtual Accessor< Shader > CreateShader(const BaseFactory< Shader >& factory) = 0;
+ virtual Accessor<Shader> CreateShader( const BaseFactory<Shader>& factory ) = 0;
/**
* @brief Create a new object
*/
- virtual Accessor< Texture > CreateTexture(const BaseFactory< Texture >& factory) = 0;
+ virtual Accessor<Texture> CreateTexture( const BaseFactory<Texture>& factory ) = 0;
/**
* @brief Create a new object
*/
- virtual Accessor< TextureSet > CreateTextureSet(const BaseFactory< TextureSet >& factory) = 0;
+ virtual Accessor<TextureSet> CreateTextureSet( const BaseFactory<TextureSet>& factory ) = 0;
/**
* @brief Create a new object
*/
- virtual Accessor< DynamicBuffer > CreateDynamicBuffer(
- const BaseFactory< DynamicBuffer >& factory) = 0;
+ virtual Accessor<DynamicBuffer> CreateDynamicBuffer( const BaseFactory<DynamicBuffer>& factory ) = 0;
/**
* @brief Create a new object
*/
- virtual Accessor< StaticBuffer > CreateStaticBuffer(
- const BaseFactory< StaticBuffer >& factory) = 0;
+ virtual Accessor<StaticBuffer> CreateStaticBuffer( const BaseFactory<StaticBuffer>& factory ) = 0;
/**
* @brief Create a new object
*/
- virtual Accessor< Sampler > CreateSampler(const BaseFactory< Sampler >& factory) = 0;
+ virtual Accessor<Sampler> CreateSampler( const BaseFactory<Sampler>& factory ) = 0;
/**
* @brief Create a new object
*/
- virtual Accessor< Framebuffer > CreateFramebuffer(const BaseFactory< Framebuffer >& factory) = 0;
+ virtual Accessor<Framebuffer> CreateFramebuffer( const BaseFactory<Framebuffer>& factory ) = 0;
/**
* @brief Get a render list
*/
virtual void GetRenderItemList() = 0;
+ /**
+ * @brief Create a buffer
+ */
+ template<typename T>
+ std::unique_ptr<GenericBuffer<T>> CreateBuffer( size_t numberOfElements );
+
+ /**
+ * @brief Submit a render command
+ */
+ virtual void SubmitCommand( API::RenderCommand&& command ) = 0;
+
+ /**
+ * @brief Mark the beginning of a frame
+ */
+ virtual void BeginFrame() = 0;
+
+ /**
+ * @brief Mark the end of a frame
+ */
+ virtual void EndFrame() = 0;
+
public:
// not copyable
- Controller(const Controller&) = delete;
- Controller& operator=(const Controller&) = delete;
+ Controller( const Controller& ) = delete;
+ Controller& operator=( const Controller& ) = delete;
virtual ~Controller() = default;
protected:
// derived types should not be moved direcly to prevent slicing
- Controller(Controller&&) = default;
- Controller& operator=(Controller&&) = default;
+ Controller( Controller&& ) = default;
+ Controller& operator=( Controller&& ) = default;
/**
* Objects of this type should not directly.
*/
Controller() = default;
+
+ /**
+ * @brief create an element for the given number of elements and element size
+ */
+ virtual std::unique_ptr<char> CreateBuffer( size_t numberOfElements, size_t elementSize ) = 0;
+
+private:
};
+template<typename T>
+std::unique_ptr<GenericBuffer<T>> Controller::CreateBuffer( size_t numberOfElements )
+{
+ return std::make_unique<GenericBuffer<T>>(numberOfElements, std::move(CreateBuffer( numberOfElements, sizeof( T ) )));
+}
+
} // namespace API
} // namespace Graphics
} // namespace Dali
--- /dev/null
+#ifndef DALI_GRAPHICS_API_FRAME_H
+#define DALI_GRAPHICS_API_FRAME_H
+
+/*
+ * Copyright (c) 2018 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+/**
+ * @brief Interface class for Frame types in the graphics API.
+ *
+ * A frame is used to mark the beginning and end of a presentation cycle.
+ */
+class Frame
+{
+public:
+
+ // not copyable
+ Frame(const Frame&) = delete;
+ Frame& operator=(const Frame&) = delete;
+
+ virtual ~Frame() = default;
+
+//TODO: @todo this should be protected
+
+
+ // derived types should not be moved direcly to prevent slicing
+ Frame(Frame&&) = default;
+ Frame& operator=(Frame&&) = default;
+
+ /**
+ * Objects of this type should not directly.
+ */
+ Frame() = default;
+};
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_FRAME_H
#ifndef DALI_GRAPHICS_API_GENERIC_BUFFER_H
#define DALI_GRAPHICS_API_GENERIC_BUFFER_H
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
*
*/
-#include <vector>
+#include <cstddef>
+#include <memory>
namespace Dali
{
{
namespace API
{
+class GenericBufferBase
+{
+public:
+ enum class UsageHint
+ {
+ FRAME_CONSTANTS,
+ PRIMITIVE_UNIFORMS,
+ ATTRIBUTES,
+ INSTANCE,
+ INDEX_BUFFER,
+ };
+
+ GenericBufferBase( size_t size, std::unique_ptr<char>&& data ) : mSize{size}, mData( std::move( data ) )
+ {
+ }
+
+ size_t GetSize() const
+ {
+ return mSize;
+ }
+
+ virtual ~GenericBufferBase() = default;
+
+protected:
+ char* GetDataBase()
+ {
+ return mData.get();
+ }
+
+ // derived types should not be moved direcly to prevent slicing
+ GenericBufferBase( GenericBufferBase&& ) = default;
+ GenericBufferBase& operator=( GenericBufferBase&& ) = default;
+
+ // not copyable
+ GenericBufferBase( const GenericBufferBase& ) = delete;
+ GenericBufferBase& operator=( const GenericBufferBase& ) = delete;
+
+private:
+ size_t mSize;
+ std::unique_ptr<char> mData;
+};
/**
* @brief Interface class for GenericBuffer types in the graphics API.
*/
-template< typename Base, typename Structure >
-class GenericBuffer final : public Base
+template<typename T>
+class GenericBuffer final : public GenericBufferBase
{
public:
- GenericBuffer(size_t size) = default;
-
- // not copyable
- GenericBuffer(const GenericBuffer&) = delete;
- GenericBuffer& operator=(const GenericBuffer&) = delete;
+ GenericBuffer( size_t numberOfElements, std::unique_ptr<char>&& data )
+ : GenericBufferBase( numberOfElements * sizeof( T ), std::move( data ) ){};
virtual ~GenericBuffer() = default;
-protected:
- // derived types should not be moved direcly to prevent slicing
- GenericBuffer(GenericBuffer&&) = default;
- GenericBuffer& operator=(GenericBuffer&&) = default;
+ GenericBuffer( GenericBuffer&& ) = default;
+ GenericBuffer& operator=( GenericBuffer&& ) = default;
-private:
+ // not copyable
+ GenericBuffer( const GenericBuffer& ) = delete;
+ GenericBuffer& operator=( const GenericBuffer& ) = delete;
- std::vector< Structure > mData;
+ T* GetData()
+ {
+ return reinterpret_cast<T*>( GenericBufferBase::GetDataBase() );
+ }
};
} // namespace API
--- /dev/null
+#ifndef DALI_GRAPHICS_API_RENDER_COMMAND_H
+#define DALI_GRAPHICS_API_RENDER_COMMAND_H
+
+/*
+ * Copyright (c) 2018 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <tuple>
+#include <utility>
+#include <vector>
+
+// INTERNAL INCLUDES
+#include <dali/graphics-api/graphics-api-generic-buffer.h>
+#include <dali/graphics-api/utility/utility-builder.h>
+#include <dali/graphics-api/utility/utility-strong-type.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+using PrimitiveCount = Utility::StrongType<size_t, struct PrimitiveCountTag>;
+using BufferInfo = std::unique_ptr<GenericBufferBase>;
+using BufferList = Utility::StrongType<std::vector<BufferInfo>, struct BufferListTag>;
+
+/**
+ * @brief Interface class for RenderCommand types in the graphics API.
+ */
+class RenderCommand final
+{
+public:
+ RenderCommand( PrimitiveCount primitiveCount, BufferList&& bufferList )
+ : mPrimitiveCount{primitiveCount}, mBufferList{std::move( bufferList )}
+ {
+ }
+
+ // derived types should not be moved direcly to prevent slicing
+ RenderCommand( RenderCommand&& ) = default;
+ RenderCommand& operator=( RenderCommand&& ) = default;
+
+ // not copyable
+ RenderCommand( const RenderCommand& ) = delete;
+ RenderCommand& operator=( const RenderCommand& ) = delete;
+
+ ~RenderCommand() = default;
+
+private:
+ PrimitiveCount mPrimitiveCount;
+ BufferList mBufferList;
+};
+
+using RenderCommandBuilder = Utility::Builder<RenderCommand, PrimitiveCount, BufferList>;
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_RENDER_COMMAND_H
#define DALI_GRAPHICS_ASSERTS_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
--- /dev/null
+#ifndef DALI_GRAPHICS_UTILITY_BUILDER_H
+#define DALI_GRAPHICS_UTILITY_BUILDER_H
+
+/*
+ * Copyright (c) 2018 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <cstddef>
+#include <utility>
+#include <tuple>
+
+// INTERNAL INCLUDES
+#include <dali/graphics-api/utility/utility-traits.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace Utility
+{
+
+template<typename T, typename... Params>
+class Builder
+{
+public:
+ template<typename... Values>
+ Builder( Values&&... values ) : mParameters{}
+ {
+ SetParameters( values... );
+ }
+
+ template<typename Return>
+ operator Return() const
+ {
+ return Build( std::index_sequence_for<Params...>{} );
+ }
+
+ auto Build() const
+ {
+ return Build( std::index_sequence_for<Params...>{} );
+ }
+
+ template<typename V>
+ void Set( V&& value )
+ {
+ SetParameters( std::forward<V>( value ) );
+ }
+
+private:
+ void SetParameters() const {};
+
+ template<typename V>
+ void SetParameters( V&& value )
+ {
+ std::get<std::remove_reference_t<V>>( mParameters ) = std::forward<V>( value );
+ }
+
+ template<typename Head, typename... Tail>
+ void SetParameters( Head&& head, Tail&&... tail )
+ {
+ SetParameters( std::forward<Head>( head ) );
+ SetParameters( std::forward<Tail...>( tail... ) );
+ }
+
+ template<size_t... Is>
+ T Build( std::index_sequence<Is...> ) const
+ {
+ return T(std::forward<Params>(std::get<Is>(std::forward<std::tuple<Params...>>( mParameters ) ))...);
+ }
+
+private: // data
+ std::tuple<Params...> mParameters;
+};
+
+} // namespace Utility
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_UTILITY_BUILDER_H
\ No newline at end of file
#define DALI_GRAPHICS_UTILITY_QUEUE_H
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
--- /dev/null
+#ifndef DALI_GRAPHICS_UTILITY_STRONG_TYPE_H
+#define DALI_GRAPHICS_UTILITY_STRONG_TYPE_H
+
+/*
+ * Copyright (c) 2018 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <utility>
+#include <ostream>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace Utility
+{
+
+/**
+ * @brief Type wrapper to enforce scemantics in other types
+ */
+template<typename T, typename Tag>
+class StrongType final
+{
+public:
+ explicit StrongType( T value ) noexcept : mValue( std::move( value ) )
+ {
+ }
+
+ StrongType() = default;
+
+ const T& Get() const noexcept
+ {
+ return mValue;
+ }
+
+ T& Get() noexcept
+ {
+ return mValue;
+ }
+
+ const T& operator*() const noexcept
+ {
+ return mValue;
+ }
+
+ T& operator*() noexcept
+ {
+ return mValue;
+ }
+
+private:
+ T mValue;
+};
+
+template<typename T, typename Tag>
+std::ostream& operator<<( std::ostream& os, const StrongType<T, Tag>& value )
+{
+ os << value.Get();
+ return os;
+}
+
+} // namespace Utility
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_UTILITY_STRONG_TYPE_H
\ No newline at end of file
#define DALI_GRAPHICS_SYNCHRONIZED_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
--- /dev/null
+#ifndef DALI_GRAPHICS_UTILITY_TRAITS_H
+#define DALI_GRAPHICS_UTILITY_TRAITS_H
+
+/*
+ * Copyright (c) 2018 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <memory>
+#include <type_traits>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace Utility
+{
+
+template<typename T>
+struct BasicType
+{
+ using StorageT = T;
+ using AccessT = T;
+ using ValueT = T;
+};
+
+template<typename T>
+struct ComplexType
+{
+ using StorageT = T;
+ using AccessT = const T&;
+ using ValueT = T;
+};
+
+template<typename T, template<typename...> class Ptr, typename...Ts>
+struct SmartPointerType
+{
+ using StorageT = Ptr<T, Ts...>;
+ using AccessT = T&;
+ using ValueT = T;
+};
+
+// Default types
+template<typename T> struct TraitsType : ComplexType<T> {};
+
+// Pointer types
+template<typename T, typename D>
+struct TraitsType<std::unique_ptr<T, D>> : SmartPointerType<T, std::unique_ptr, D>
+{
+};
+template<typename T>
+struct TraitsType<std::shared_ptr<T>> : SmartPointerType<T, std::shared_ptr>
+{
+};
+
+// Basic types
+template<> struct TraitsType<signed char> : BasicType<signed char> { };
+template<> struct TraitsType<unsigned char> : BasicType<unsigned char> { };
+template<> struct TraitsType<signed short> : BasicType<signed short> { };
+template<> struct TraitsType<unsigned short> : BasicType<unsigned short> { };
+template<> struct TraitsType<signed long> : BasicType<signed long> { };
+template<> struct TraitsType<unsigned long> : BasicType<unsigned long> { };
+template<> struct TraitsType<signed long long> : BasicType<signed long long> { };
+template<> struct TraitsType<unsigned long long> : BasicType<unsigned long long> { };
+template<> struct TraitsType<float> : BasicType<float> { };
+template<> struct TraitsType<double> : BasicType<double> { };
+
+// Invalid tyoes
+
+template<typename T> struct TraitsType<T*> {};
+template<typename T> struct TraitsType<const T*> {};
+template<typename T> struct TraitsType<T&> {};
+template<typename T> struct TraitsType<const T&> {};
+
+} // namespace Utility
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_UTILITY_TRAITS_H
\ No newline at end of file
$(graphics_src_dir)/vulkan/vulkan-pipeline.cpp \
$(graphics_src_dir)/vulkan/vulkan-buffer.cpp \
$(graphics_src_dir)/vulkan/vulkan-graphics.cpp \
- $(graphics_src_dir)/vulkan/vulkan-shader.cpp
+ $(graphics_src_dir)/vulkan/vulkan-shader.cpp \
+ $(graphics_src_dir)/vulkan/vulkan-graphics-controller.cpp
#define DALI_GRAPHICS_CONTROLLER_H
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
/**
* @brief Controller implementation of the graphics API
*/
-class Controller final : public API::Controller
+class Controller : public API::Controller
{
public:
virtual API::Accessor< API::Shader > CreateShader(
virtual ~Controller() = default;
-private:
+
+protected:
ObjectOwner< API::Shader > mShaders;
ObjectOwner< API::Texture > mTextures;
ObjectOwner< API::TextureSet > mTextureSets;
struct Framebuffer::Impl
{
Impl( Framebuffer& owner, Graphics& graphics, uint32_t width, uint32_t height )
- : mInterface( owner ), mGraphics( graphics )
+ : mInterface( owner ), mGraphics( graphics ), mColorImageViewAttachments{}, mDepthStencilImageViewAttachment()
{
}
mVkFramebuffer = VkAssert( mGraphics.GetDevice().createFramebuffer( info, mGraphics.GetAllocator() ) );
}
- void SetAttachment( Handle<Image> image, Framebuffer::AttachmentType type, uint32_t index )
+ void SetAttachment( ImageViewRef imageViewRef, Framebuffer::AttachmentType type, uint32_t index )
{
- std::vector<Handle<Image>>& attachments =
- type == AttachmentType::COLOR ? mColorAttachments : mDepthStencilAttachments;
-
- if( attachments.size() <= index )
+ // TODO: all array-type atyachments
+ if( type == AttachmentType::COLOR )
{
- attachments.resize( index + 1 );
+ auto& attachments = mColorImageViewAttachments;
+ if( attachments.size() <= index )
+ {
+ attachments.resize( index + 1 );
+ }
+ attachments[index] = imageViewRef;
+ }
+ else if( type == AttachmentType::DEPTH_STENCIL )
+ {
+ mDepthStencilImageViewAttachment = imageViewRef;
}
- attachments[index] = image;
- }
-
- ImageRef GetAttachmentImage( AttachmentType type, uint32_t index ) const
- {
- return ImageRef();
}
ImageViewRef GetAttachmentImageView( AttachmentType type, uint32_t index ) const
{
+ switch( type )
+ {
+ case AttachmentType::COLOR:
+ {
+ return mColorImageViewAttachments[index];
+ }
+ case AttachmentType::DEPTH_STENCIL:
+ {
+ return mDepthStencilImageViewAttachment;
+ }
+ case AttachmentType::DEPTH:
+ case AttachmentType::INPUT:
+ case AttachmentType::RESOLVE:
+ case AttachmentType::PRESERVE:
+ {
+ return ImageViewRef();
+ }
+ }
return ImageViewRef();
}
Framebuffer& mInterface;
Graphics& mGraphics;
- uint32_t mWidth;
- uint32_t mHeight;
- std::vector<Handle<Image>> mColorAttachments;
- std::vector<Handle<Image>> mDepthStencilAttachments;
+ uint32_t mWidth;
+ uint32_t mHeight;
- std::vector<ImageView> mImageViewAttachments;
- vk::Framebuffer mVkFramebuffer;
- vk::RenderPass mVkRenderPass;
+ std::vector<ImageViewRef> mColorImageViewAttachments;
+ ImageViewRef mDepthStencilImageViewAttachment;
+ vk::Framebuffer mVkFramebuffer;
+ vk::RenderPass mVkRenderPass;
bool mInitialised{false};
};
-Handle<Framebuffer> Framebuffer::New( Graphics& graphics, uint32_t width, uint32_t height )
+FramebufferRef Framebuffer::New( Graphics& graphics, uint32_t width, uint32_t height )
{
return FramebufferRef();
}
-void Framebuffer::SetAttachment( Handle<Image> image, Framebuffer::AttachmentType type, uint32_t index )
+void Framebuffer::SetAttachment( ImageViewRef imageViewRef, Framebuffer::AttachmentType type, uint32_t index )
{
- mImpl->SetAttachment( image, type, index );
+ mImpl->SetAttachment( imageViewRef, type, index );
}
uint32_t Framebuffer::GetWidth() const
return mImpl->mHeight;
}
-Handle<Image> Framebuffer::GetAttachmentImage( AttachmentType type, uint32_t index ) const
-{
- return mImpl->GetAttachmentImage( type, index );
-}
-
Handle<ImageView> Framebuffer::GetAttachmentImageView( AttachmentType type, uint32_t index ) const
{
return mImpl->GetAttachmentImageView( type, index );
{
COLOR,
DEPTH_STENCIL,
+ DEPTH,
INPUT,
RESOLVE,
PRESERVE
};
- static Handle<Framebuffer> New( Graphics& graphics, uint32_t width, uint32_t height );
+ static FramebufferRef New( Graphics& graphics, uint32_t width, uint32_t height );
uint32_t GetWidth() const;
uint32_t GetHeight() const;
- Handle<Image> GetAttachmentImage( AttachmentType type, uint32_t index ) const;
+ ImageViewRef GetAttachmentImageView( AttachmentType type, uint32_t index ) const;
+
+ void SetAttachment( ImageViewRef imageViewRef, Framebuffer::AttachmentType type, uint32_t index );
- Handle<ImageView> GetAttachmentImageView( AttachmentType type, uint32_t index ) const;
- void SetAttachment( Handle<Image> image, Framebuffer::AttachmentType type, uint32_t index );
private:
--- /dev/null
+#include <dali/graphics/vulkan/vulkan-graphics-controller.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace Vulkan
+{
+// TODO: @todo temporarily ignore missing return type, will be fixed later
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wreturn-type"
+API::Accessor<API::Shader> Controller::CreateShader( const API::BaseFactory<API::Shader>& factory )
+{
+}
+
+API::Accessor<API::Texture> Controller::CreateTexture( const API::BaseFactory<API::Texture>& factory )
+{
+}
+
+API::Accessor<API::TextureSet> Controller::CreateTextureSet( const API::BaseFactory<API::TextureSet>& factory )
+{
+}
+
+API::Accessor<API::DynamicBuffer> Controller::CreateDynamicBuffer( const API::BaseFactory<API::DynamicBuffer>& factory )
+{
+}
+
+API::Accessor<API::StaticBuffer> Controller::CreateStaticBuffer( const API::BaseFactory<API::StaticBuffer>& factory )
+{
+}
+
+API::Accessor<API::Sampler> Controller::CreateSampler( const API::BaseFactory<API::Sampler>& factory )
+{
+}
+
+API::Accessor<API::Framebuffer> Controller::CreateFramebuffer( const API::BaseFactory<API::Framebuffer>& factory )
+{
+}
+#pragma GCC diagnostic pop
+
+void Controller::GetRenderItemList()
+{
+}
+
+void Controller::SubmitCommand( API::RenderCommand&& command )
+{
+}
+
+void Controller::BeginFrame()
+{
+}
+
+void Controller::EndFrame()
+{
+}
+
+} // namespace Vulkan
+} // namespace Graphics
+} // namespace Dali
--- /dev/null
+#ifndef DALI_GRAPHICS_VULAKN_GRAPHICS_CONTROLLER_H
+#define DALI_GRAPHICS_VULAKN_GRAPHICS_CONTROLLER_H
+
+/*
+ * Copyright (c) 2018 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/graphics/graphics-controller.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace Vulkan
+{
+/**
+ * @brief Interface class for Manager types in the graphics API.
+ */
+class Controller : public Graphics::Controller
+{
+public:
+ /**
+ * @brief Create a new object
+ */
+ API::Accessor<API::Shader> CreateShader( const API::BaseFactory<API::Shader>& factory ) override;
+
+ /**
+ * @brief Create a new object
+ */
+ API::Accessor<API::Texture> CreateTexture( const API::BaseFactory<API::Texture>& factory ) override;
+
+ /**
+ * @brief Create a new object
+ */
+ API::Accessor<API::TextureSet> CreateTextureSet( const API::BaseFactory<API::TextureSet>& factory ) override;
+
+ /**
+ * @brief Create a new object
+ */
+ API::Accessor<API::DynamicBuffer> CreateDynamicBuffer( const API::BaseFactory<API::DynamicBuffer>& factory ) override;
+
+ /**
+ * @brief Create a new object
+ */
+ API::Accessor<API::StaticBuffer> CreateStaticBuffer( const API::BaseFactory<API::StaticBuffer>& factory ) override;
+
+ /**
+ * @brief Create a new object
+ */
+ API::Accessor<API::Sampler> CreateSampler( const API::BaseFactory<API::Sampler>& factory ) override;
+
+ /**
+ * @brief Create a new object
+ */
+ API::Accessor<API::Framebuffer> CreateFramebuffer( const API::BaseFactory<API::Framebuffer>& factory ) override;
+
+ /**
+ * @brief Get a render list
+ */
+ void GetRenderItemList() override;
+
+ void SubmitCommand(API::RenderCommand&& command) override;
+
+ void BeginFrame() override;
+
+ void EndFrame() override;
+
+public:
+ // not copyable
+ Controller( const Controller& ) = delete;
+ Controller& operator=( const Controller& ) = delete;
+
+ virtual ~Controller() = default;
+
+protected:
+ // derived types should not be moved direcly to prevent slicing
+ Controller( Controller&& ) = default;
+ Controller& operator=( Controller&& ) = default;
+
+ /**
+ * Objects of this type should not directly.
+ */
+ Controller() = default;
+
+private:
+
+ struct Impl;
+ std::unique_ptr<Impl> mImpl;
+
+};
+
+} // namespace Vulkan
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_VULAKN_GRAPHICS_CONTROLLER_H
return retval;
}
+ImageViewRef ImageView::New( Graphics& graphics, ImageRef image )
+{
+ // create reference, image may be null
+ auto retval = ImageViewRef( new ImageView( graphics, image, vk::ImageViewCreateInfo{} ) );
+ if(image)
+ {
+
+ }
+ return retval;
+}
+
ImageView::ImageView( Graphics& graphics, ImageRef image, const VkImageViewCreateInfo& createInfo )
{
mImpl = MakeUnique<Impl>( *this, graphics, image, createInfo );
{
public:
+ /**
+ * Creates ImageView according to the given spec
+ * @param graphics
+ * @param image
+ * @param info
+ * @return
+ */
static ImageViewRef New( Graphics& graphics, ImageRef image, vk::ImageViewCreateInfo info );
+ /**
+ * Creates default image view which includes single layer and level, aspect
+ * based on image format, whole area, always 2D
+ * @param graphics
+ * @param image
+ * @return
+ */
+ static ImageViewRef New( Graphics& graphics, ImageRef image = ImageRef() );
+
+
virtual ~ImageView() override;
/**
*/
ImageRef GetImage() const;
+ /**
+ *
+ * @param format
+ */
+ void SetFormat( vk::Format format );
+
+ /**
+ *
+ * @param componentMapping
+ */
+ void SetComponents( vk::ComponentMapping componentMapping );
+
+ /**
+ *
+ * @param viewType
+ */
+ void SetViewType( vk::ImageViewType viewType );
+
+ /**
+ *
+ * @param layerCount
+ */
+ void SetLayerCount( uint32_t layerCount );
+
+ /**
+ *
+ * @param layerCount
+ */
+ void SetLevelCount( uint32_t layerCount );
+
+ /**
+ *
+ * @param layerCount
+ */
+ void SetBaseMipmapLevel( uint32_t layerCount );
+
+ /**
+ *
+ * @param layer
+ */
+ void SetBaseArrayLayer( uint32_t layer );
+
+ /**
+ *
+ * @param aspectMask
+ */
+ void SetImageAspectMask( vk::ImageAspectFlags aspectMask );
+
+ /**
+ *
+ * @return
+ */
+ uint32_t GetLayerCount() const;
+
+ /**
+ *
+ * @return
+ */
+ uint32_t GetLevelCount() const;
+
+ /**
+ *
+ * @return
+ */
+ uint32_t GetBaseMipmapLevel() const;
+
+ /**
+ *
+ * @return
+ */
+ uint32_t GetBaseArrayLayer() const;
+
+ /**
+ *
+ * @return
+ */
+ vk::ImageAspectFlags GetImageAspectMask() const;
+
+ /**
+ * Creates immediately the image view. Otherwise implementation will
+ * pick the right time to create the object. All setters are disabled
+ * once the view has been created
+ * @return
+ */
+ bool Create();
+
private:
ImageView( Graphics& graphics, ImageRef image, const VkImageViewCreateInfo& createInfo );
#endif
#include <glm/glm.hpp>
+#include <glm/gtc/matrix_transform.hpp>
#include <glm/matrix.hpp>
#include <glm/vector_relational.hpp>
-#include <glm/gtc/matrix_transform.hpp>
using namespace glm;
+#include <dali/integration-api/graphics/graphics.h>
+#include <dali/integration-api/graphics/vulkan/vk-surface-factory.h>
#include <dali/integration-api/graphics/vulkan/vulkan-hpp-wrapper.h>
-#include <dali/integration-api/graphics/vulkan/vk-surface-factory.h>
-#include <dali/integration-api/graphics/graphics.h>
-#include <xcb/xcb.h>
#include <unistd.h>
+#include <xcb/xcb.h>
// internals
-#include <dali/graphics/vulkan/vulkan-buffer.h>
-#include <dali/graphics/vulkan/vulkan-graphics.h>
-#include <dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-manager.h>
-#include <dali/graphics/vulkan/vulkan-shader.h>
-#include <dali/graphics/vulkan/vulkan-descriptor-set.h>
-#include <dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-manager.h>
+#include "generated/spv-shaders-gen.h"
+
#include <dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-allocator.h>
#include <dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-handle.h>
-#include <dali/graphics/vulkan/vulkan-pipeline.h>
-#include <dali/graphics/vulkan/vulkan-command-pool.h>
+#include <dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-manager.h>
+#include <dali/graphics/vulkan/vulkan-buffer.h>
#include <dali/graphics/vulkan/vulkan-command-buffer.h>
-#include <dali/graphics/vulkan/vulkan-surface.h>
+#include <dali/graphics/vulkan/vulkan-command-pool.h>
#include <dali/graphics/vulkan/vulkan-descriptor-set.h>
-
-#include "generated/spv-shaders-gen.h"
+#include <dali/graphics/vulkan/vulkan-framebuffer.h>
+#include <dali/graphics/vulkan/vulkan-graphics.h>
+#include <dali/graphics/vulkan/vulkan-image.h>
+#include <dali/graphics/vulkan/vulkan-pipeline.h>
+#include <dali/graphics/vulkan/vulkan-shader.h>
+#include <dali/graphics/vulkan/vulkan-surface.h>
#define USE_XLIB 0
#include <iostream>
-using Dali::Integration::Graphics::Graphics;
-using Dali::Integration::Graphics::Vulkan::VkSurfaceFactory;
using Dali::Graphics::Vulkan::Buffer;
-using Dali::Graphics::Vulkan::Shader;
+using Dali::Graphics::Vulkan::CommandBuffer;
+using Dali::Graphics::Vulkan::CommandPool;
+using Dali::Graphics::Vulkan::DescriptorPool;
using Dali::Graphics::Vulkan::DescriptorSetLayout;
-using Dali::Graphics::Vulkan::GpuMemoryManager;
using Dali::Graphics::Vulkan::GpuMemoryAllocator;
-using Dali::Graphics::Vulkan::Shader;
-using Dali::Graphics::Vulkan::ShaderRef;
+using Dali::Graphics::Vulkan::GpuMemoryManager;
using Dali::Graphics::Vulkan::Pipeline;
using Dali::Graphics::Vulkan::PipelineRef;
-using Dali::Graphics::Vulkan::CommandPool;
-using Dali::Graphics::Vulkan::CommandBuffer;
-using Dali::Graphics::Vulkan::DescriptorPool;
+using Dali::Graphics::Vulkan::Shader;
+using Dali::Graphics::Vulkan::ShaderRef;
+using Dali::Integration::Graphics::Graphics;
+using Dali::Integration::Graphics::Vulkan::VkSurfaceFactory;
extern std::vector<uint8_t> VSH;
extern std::vector<uint8_t> FSH;
-template< typename T, typename... Args >
-std::unique_ptr< T > MakeUnique(Args&&... args)
+template<typename T, typename... Args>
+std::unique_ptr<T> MakeUnique( Args&&... args )
{
- return std::unique_ptr< T >(new T(std::forward< Args >(args)...));
+ return std::unique_ptr<T>( new T( std::forward<Args>( args )... ) );
}
-
class VkSurfaceXlib : public Dali::Integration::Graphics::Vulkan::VkSurfaceFactory
{
public:
* @param display
* @param window
*/
- VkSurfaceXlib(Display* display, Window window)
- : VkSurfaceFactory(), mDisplay(display), mWindow(window)
+ VkSurfaceXlib( Display* display, Window window ) : VkSurfaceFactory(), mDisplay( display ), mWindow( window )
{
}
- virtual vk::SurfaceKHR Create(vk::Instance instance, vk::AllocationCallbacks* allocCallbacks,
- vk::PhysicalDevice physicalDevice) const override
+ virtual vk::SurfaceKHR Create( vk::Instance instance,
+ vk::AllocationCallbacks* allocCallbacks,
+ vk::PhysicalDevice physicalDevice ) const override
{
vk::XlibSurfaceCreateInfoKHR info;
- info.setDpy(mDisplay).setWindow(mWindow);
- auto retval = instance.createXlibSurfaceKHR(info, allocCallbacks).value;
+ info.setDpy( mDisplay ).setWindow( mWindow );
+ auto retval = instance.createXlibSurfaceKHR( info, allocCallbacks ).value;
return retval;
}
* @param display
* @param window
*/
- VkSurfaceXcb(xcb_connection_t* connection, xcb_window_t window)
- : VkSurfaceFactory{}, mConnection(connection), mWindow(window)
+ VkSurfaceXcb( xcb_connection_t* connection, xcb_window_t window )
+ : VkSurfaceFactory{}, mConnection( connection ), mWindow( window )
{
}
- virtual vk::SurfaceKHR Create(vk::Instance instance, vk::AllocationCallbacks* allocCallbacks,
- vk::PhysicalDevice physicalDevice) const override
+ virtual vk::SurfaceKHR Create( vk::Instance instance,
+ vk::AllocationCallbacks* allocCallbacks,
+ vk::PhysicalDevice physicalDevice ) const override
{
vk::XcbSurfaceCreateInfoKHR info;
- info.setConnection(mConnection).setWindow(mWindow);
- auto retval = instance.createXcbSurfaceKHR(info, allocCallbacks).value;
+ info.setConnection( mConnection ).setWindow( mWindow );
+ auto retval = instance.createXcbSurfaceKHR( info, allocCallbacks ).value;
return retval;
}
~xlib_window_t()
{
- XDestroyWindow(display, window);
+ XDestroyWindow( display, window );
}
};
-std::unique_ptr< xlib_window_t > create_xlib_window(int width, int height)
+std::unique_ptr<xlib_window_t> create_xlib_window( int width, int height )
{
- std::unique_ptr< xlib_window_t > wnd{new xlib_window_t};
+ std::unique_ptr<xlib_window_t> wnd{new xlib_window_t};
// 1. Create Window ( done by DALI
wnd->width = width;
wnd->height = height;
- wnd->display = XOpenDisplay(nullptr);
- auto defaultScreen = DefaultScreen(wnd->display);
- wnd->window =
- XCreateSimpleWindow(wnd->display, RootWindow(wnd->display, defaultScreen), 0, 0, wnd->width,
- wnd->height, 1, BlackPixel(wnd->display, defaultScreen),
- WhitePixel(wnd->display, defaultScreen));
-
- XSelectInput(wnd->display, wnd->window, ExposureMask | KeyPressMask);
- XMapWindow(wnd->display, wnd->window);
- XSync(wnd->display, false);
+ wnd->display = XOpenDisplay( nullptr );
+ auto defaultScreen = DefaultScreen( wnd->display );
+ wnd->window = XCreateSimpleWindow( wnd->display,
+ RootWindow( wnd->display, defaultScreen ),
+ 0,
+ 0,
+ wnd->width,
+ wnd->height,
+ 1,
+ BlackPixel( wnd->display, defaultScreen ),
+ WhitePixel( wnd->display, defaultScreen ) );
+
+ XSelectInput( wnd->display, wnd->window, ExposureMask | KeyPressMask );
+ XMapWindow( wnd->display, wnd->window );
+ XSync( wnd->display, false );
return wnd;
}
~xcb_window_t()
{
- xcb_destroy_window(connection, window);
+ xcb_destroy_window( connection, window );
}
};
-std::unique_ptr< Test::xcb_window_t > create_xcb_window(int width, int height)
+std::unique_ptr<Test::xcb_window_t> create_xcb_window( int width, int height )
{
- std::unique_ptr< Test::xcb_window_t > wnd{new Test::xcb_window_t};
+ std::unique_ptr<Test::xcb_window_t> wnd{new Test::xcb_window_t};
// 1. Create Window ( done by DALI
wnd->width = width;
wnd->height = height;
- int screenNum(0);
+ int screenNum( 0 );
- xcb_connection_t* connection = xcb_connect(NULL, &screenNum);
- const xcb_setup_t* setup = xcb_get_setup(connection);
- xcb_screen_iterator_t iter = xcb_setup_roots_iterator(setup);
- for(int i = 0; i < screenNum; ++i)
- xcb_screen_next(&iter);
+ xcb_connection_t* connection = xcb_connect( NULL, &screenNum );
+ const xcb_setup_t* setup = xcb_get_setup( connection );
+ xcb_screen_iterator_t iter = xcb_setup_roots_iterator( setup );
+ for( int i = 0; i < screenNum; ++i )
+ xcb_screen_next( &iter );
- xcb_screen_t* screen = iter.data;
- ::xcb_window_t window = xcb_generate_id(connection);
+ xcb_screen_t* screen = iter.data;
+ ::xcb_window_t window = xcb_generate_id( connection );
uint32_t mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
uint32_t values[] = {screen->white_pixel, XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS};
- xcb_create_window(connection, XCB_COPY_FROM_PARENT, window, screen->root, 0, 0, wnd->width,
- wnd->height, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, mask,
- values);
-
- xcb_map_window(connection, window);
+ xcb_create_window( connection,
+ XCB_COPY_FROM_PARENT,
+ window,
+ screen->root,
+ 0,
+ 0,
+ wnd->width,
+ wnd->height,
+ 0,
+ XCB_WINDOW_CLASS_INPUT_OUTPUT,
+ screen->root_visual,
+ mask,
+ values );
+
+ xcb_map_window( connection, window );
const uint32_t coords[] = {100, 100};
- xcb_configure_window(connection, window, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords);
- xcb_flush(connection);
+ xcb_configure_window( connection, window, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords );
+ xcb_flush( connection );
wnd->connection = connection;
wnd->window = window;
return wnd;
}
-}
+} // namespace Test
namespace VulkanTest
{
-
-Dali::Graphics::Vulkan::GpuMemoryBlockRef test_gpu_memory_manager( Dali::Graphics::Vulkan::Graphics& graphics,
- GpuMemoryManager& gpuManager,
- const Dali::Graphics::Vulkan::Handle<Buffer>& buffer )
+Dali::Graphics::Vulkan::GpuMemoryBlockRef test_gpu_memory_manager(
+ Dali::Graphics::Vulkan::Graphics& graphics,
+ GpuMemoryManager& gpuManager,
+ const Dali::Graphics::Vulkan::Handle<Buffer>& buffer )
{
- auto device = graphics.GetDevice();
+ auto device = graphics.GetDevice();
auto& allocator = graphics.GetAllocator();
auto& gpuAllocator = gpuManager.GetDefaultAllocator();
mat4 viewMat;
mat4 projMat;
vec4 color;
-} __attribute__((aligned(16)));
-
+} __attribute__( ( aligned( 16 ) ) );
mat4 MVP;
-
-
-
-template <class T>
+template<class T>
void update_buffer( Dali::Graphics::Vulkan::BufferRef buffer, T& value )
{
- auto ptr = reinterpret_cast<T*>(buffer->GetMemoryHandle()->Map());
- *ptr = value;
+ auto ptr = reinterpret_cast<T*>( buffer->GetMemoryHandle()->Map() );
+ *ptr = value;
buffer->GetMemoryHandle()->Unmap();
}
UniformData ub;
ub.modelMat = mat4{1.0f};
- ub.modelMat = glm::translate( ub.modelMat, vec3( x, x, 0.0f ));
- ub.modelMat = glm::rotate( ub.modelMat, glm::radians( x ), glm::vec3( 0.0f, 0.0f, 1.0f) );
- ub.viewMat = lookAt( vec3( 0.0f, 0.0f, 10.0f ),
- vec3( 0.0f, 0.0f, 0.0f ),
- vec3( 0.0f, 1.0f, 0.0f ) );
+ ub.modelMat = glm::translate( ub.modelMat, vec3( x, x, 0.0f ) );
+ ub.modelMat = glm::rotate( ub.modelMat, glm::radians( x ), glm::vec3( 0.0f, 0.0f, 1.0f ) );
+ ub.viewMat = lookAt( vec3( 0.0f, 0.0f, 10.0f ), vec3( 0.0f, 0.0f, 0.0f ), vec3( 0.0f, 1.0f, 0.0f ) );
- glm::mat4 clip( 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, -1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.5f, 0.0f,
- 0.0f, 0.0f, 0.5f, 1.0f );
+ glm::mat4 clip( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 1.0f );
ub.projMat = clip * ortho( 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 100.0f );
- ub.color = vec4( x / 640.0f, x / 480.0f, 1.0f, 1.0f );
+ ub.color = vec4( x / 640.0f, x / 480.0f, 1.0f, 1.0f );
update_buffer( buffer, ub );
}
Dali::Graphics::Vulkan::BufferRef create_uniform_buffer( Dali::Graphics::Vulkan::Graphics& gr )
{
// create uniform buffer
- auto uniformBuffer = Buffer::New( gr, sizeof(UniformData), Buffer::Type::UNIFORM );
+ auto uniformBuffer = Buffer::New( gr, sizeof( UniformData ), Buffer::Type::UNIFORM );
// allocate memory
- auto memory = gr.GetDeviceMemoryManager().GetDefaultAllocator().Allocate( uniformBuffer, vk::MemoryPropertyFlagBits::eHostVisible );
+ auto memory = gr.GetDeviceMemoryManager().GetDefaultAllocator().Allocate( uniformBuffer,
+ vk::MemoryPropertyFlagBits::eHostVisible );
// bind memory
uniformBuffer->BindMemory( memory );
- auto ub = reinterpret_cast<UniformData*>(memory->Map());
+ auto ub = reinterpret_cast<UniformData*>( memory->Map() );
ub->modelMat = mat4{1.0f};
//ub->modelMat = glm::translate( ub->modelMat, vec3( 0.0f, 0.0f, 0.0f ));
- ub->viewMat = lookAt( vec3( 0.0f, 0.0f, 10.0f ),
- vec3( 0.0f, 0.0f, 0.0f ),
- vec3( 0.0f, 1.0f, 0.0f ) );
+ ub->viewMat = lookAt( vec3( 0.0f, 0.0f, 10.0f ), vec3( 0.0f, 0.0f, 0.0f ), vec3( 0.0f, 1.0f, 0.0f ) );
- glm::mat4 clip( 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, -1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.5f, 0.0f,
- 0.0f, 0.0f, 0.5f, 1.0f );
+ glm::mat4 clip( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 1.0f );
ub->projMat = clip * ortho( 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 100.0f );
- ub->color = vec4( 0.0f, 1.0f, 1.0f, 1.0f );
-
+ ub->color = vec4( 0.0f, 1.0f, 1.0f, 1.0f );
MVP = ub->projMat * ub->viewMat * ub->modelMat;
return uniformBuffer;
}
-Dali::Graphics::Vulkan::Handle<DescriptorPool>
-create_descriptor_pool( Dali::Graphics::Vulkan::Graphics& gr )
+Dali::Graphics::Vulkan::Handle<DescriptorPool> create_descriptor_pool( Dali::Graphics::Vulkan::Graphics& gr )
{
vk::DescriptorPoolSize size;
size.setDescriptorCount( 1024 ).setType( vk::DescriptorType::eUniformBuffer );
// TODO: how to organize this???
- auto pool = DescriptorPool::New( gr,
- vk::DescriptorPoolCreateInfo{}.
- setMaxSets( 1024 ).
- setPoolSizeCount(1).setPPoolSizes(&size));
+ auto pool = DescriptorPool::New(
+ gr, vk::DescriptorPoolCreateInfo{}.setMaxSets( 1024 ).setPoolSizeCount( 1 ).setPPoolSizes( &size ) );
return pool;
}
+void test_framebuffer( Dali::Graphics::Vulkan::Graphics& graphics )
+{
+ using namespace Dali::Graphics::Vulkan;
+ // framebuffer
+ auto fb = NewRef<Framebuffer>( graphics, 640, 480 );
+
+ // attachment
+ auto image = NewRef<Image>( graphics,
+ vk::ImageCreateInfo{}
+ .setFormat( vk::Format::eR32G32B32A32Sfloat )
+ .setTiling( vk::ImageTiling::eOptimal )
+ .setMipLevels( 1 )
+ .setImageType( vk::ImageType::e2D )
+ .setExtent( vk::Extent3D( 640, 480, 1 ) )
+ .setArrayLayers( 1 )
+ .setUsage( vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eColorAttachment )
+ .setSharingMode( vk::SharingMode::eExclusive )
+ .setInitialLayout( vk::ImageLayout::eUndefined )
+ .setSamples( vk::SampleCountFlagBits::e1 ) );
+
+ auto imageView = NewRef<ImageView>(
+ graphics,
+ image,
+ vk::ImageViewCreateInfo{}
+ .setFormat( vk::Format::eR32G32B32A32Sfloat )
+ .setComponents( vk::ComponentMapping(
+ vk::ComponentSwizzle::eR, vk::ComponentSwizzle::eG, vk::ComponentSwizzle::eB, vk::ComponentSwizzle::eA ) )
+ .setImage( image->GetVkImage() )
+ .setSubresourceRange( vk::ImageSubresourceRange{}
+ .setLayerCount( 1 )
+ .setLevelCount( 1 )
+ .setBaseMipLevel( 0 )
+ .setBaseArrayLayer( 0 )
+ .setAspectMask( vk::ImageAspectFlagBits::eColor ) )
+ .setViewType( vk::ImageViewType::e2D ) );
+
+ fb->SetAttachment( imageView, Framebuffer::AttachmentType::COLOR, 0u );
+
+ //fb->GetRenderPass();
+
+ //fb->SetAttachment( )
+}
+
void test_handle()
{
/*
handle.GetRefCount();*/
}
-PipelineRef
-create_pipeline( Dali::Graphics::Vulkan::Graphics& graphics,
- Dali::Graphics::Vulkan::ShaderRef vertexShader,
- Dali::Graphics::Vulkan::ShaderRef fragmentShader
- )
+PipelineRef create_pipeline( Dali::Graphics::Vulkan::Graphics& graphics,
+ Dali::Graphics::Vulkan::ShaderRef vertexShader,
+ Dali::Graphics::Vulkan::ShaderRef fragmentShader )
{
using namespace Dali::Graphics::Vulkan;
auto pipelineInfo = vk::GraphicsPipelineCreateInfo{};
- auto pipeline = Pipeline::New( graphics, pipelineInfo );
+ auto pipeline = Pipeline::New( graphics, pipelineInfo );
pipeline->SetShader( vertexShader, Shader::Type::VERTEX );
pipeline->SetShader( fragmentShader, Shader::Type::FRAGMENT );
pipeline->SetViewport( 0, 0, 640, 480 );
pipeline->SetVertexInputState(
- std::vector<vk::VertexInputAttributeDescription>{vk::VertexInputAttributeDescription{}.
- setBinding( 0 ).
- setOffset( 0 ).
- setLocation( 0 ).
- setFormat( vk::Format::eR32G32B32Sfloat )},
- std::vector<vk::VertexInputBindingDescription>{vk::VertexInputBindingDescription{}.
- setBinding( 0 ).
- setStride( sizeof(float)*3 ).
- setInputRate( vk::VertexInputRate::eVertex)}
- );
+ std::vector<vk::VertexInputAttributeDescription>{
+ vk::VertexInputAttributeDescription{}.setBinding( 0 ).setOffset( 0 ).setLocation( 0 ).setFormat(
+ vk::Format::eR32G32B32Sfloat )},
+ std::vector<vk::VertexInputBindingDescription>{vk::VertexInputBindingDescription{}
+ .setBinding( 0 )
+ .setStride( sizeof( float ) * 3 )
+ .setInputRate( vk::VertexInputRate::eVertex )} );
pipeline->SetInputAssemblyState( vk::PrimitiveTopology::eTriangleList, false );
if( !pipeline->Compile() )
int RunTestMain()
{
-
#if USE_XLIB == 1
- auto window = Test::create_xlib_window(640, 480);
- auto surfaceFactory =
- std::unique_ptr< VkSurfaceXlib >{new VkSurfaceXlib{window->display, window->window}};
+ auto window = Test::create_xlib_window( 640, 480 );
+ auto surfaceFactory = std::unique_ptr<VkSurfaceXlib>{new VkSurfaceXlib{window->display, window->window}};
#else
- auto window = Test::create_xcb_window(640, 480);
- auto surfaceFactory =
- std::unique_ptr<VkSurfaceXcb>{new VkSurfaceXcb{window->connection, window->window}};
+ auto window = Test::create_xcb_window( 640, 480 );
+ auto surfaceFactory = std::unique_ptr<VkSurfaceXcb>{new VkSurfaceXcb{window->connection, window->window}};
#endif
-
auto graphics = MakeUnique<Graphics>();
- auto fbid = graphics->Create( std::move(surfaceFactory) );
+ auto fbid = graphics->Create( std::move( surfaceFactory ) );
// access internal implementation
auto& gr = graphics->GetImplementation<Dali::Graphics::Vulkan::Graphics>();
// GPU memory manager
auto& memmgr = gr.GetDeviceMemoryManager();
- const vec3 VERTICES[] =
- {
- {0.0f, 0.0f, 0.0f},
- {320.0f, 0.0f, 0.0f},
- {0.0f, 160.0f, 0.0f},
- };
-
-
-
+ const vec3 VERTICES[] = {
+ {0.0f, 0.0f, 0.0f},
+ {320.0f, 0.0f, 0.0f},
+ {0.0f, 160.0f, 0.0f},
+ };
// shaders
auto vertexShader = Shader::New( gr, VSH_CODE.data(), VSH_CODE.size() );
- vertexShader->SetDescriptorSetLayout( 0, vk::DescriptorSetLayoutCreateInfo{}.
- setBindingCount( 1 ).
- setPBindings( std::vector<vk::DescriptorSetLayoutBinding>{
- vk::DescriptorSetLayoutBinding{}.
- setBinding( 0 ).
- setStageFlags( vk::ShaderStageFlagBits::eVertex ).
- setDescriptorType( vk::DescriptorType::eUniformBuffer ).
- setDescriptorCount( 1 )
- }.data()
- ));
+ vertexShader->SetDescriptorSetLayout(
+ 0,
+ vk::DescriptorSetLayoutCreateInfo{}.setBindingCount( 1 ).setPBindings(
+ std::vector<vk::DescriptorSetLayoutBinding>{vk::DescriptorSetLayoutBinding{}
+ .setBinding( 0 )
+ .setStageFlags( vk::ShaderStageFlagBits::eVertex )
+ .setDescriptorType( vk::DescriptorType::eUniformBuffer )
+ .setDescriptorCount( 1 )}
+ .data() ) );
auto fragmentShader = Shader::New( gr, FSH_CODE.data(), FSH_CODE.size() );
// buffer
- auto vertexBuffer = Buffer::New( gr, sizeof(float)*3*3, Buffer::Type::VERTEX );
+ auto vertexBuffer = Buffer::New( gr, sizeof( float ) * 3 * 3, Buffer::Type::VERTEX );
auto descriptorPool = create_descriptor_pool( gr );
- auto descriptorSet = descriptorPool->AllocateDescriptorSets( vk::DescriptorSetAllocateInfo{}
- .setPSetLayouts( vertexShader->GetDescriptorSetLayouts().data() )
- .setDescriptorSetCount( static_cast<uint32_t>(vertexShader->GetDescriptorSetLayouts().size())));
-
-
+ auto descriptorSet = descriptorPool->AllocateDescriptorSets(
+ vk::DescriptorSetAllocateInfo{}
+ .setPSetLayouts( vertexShader->GetDescriptorSetLayouts().data() )
+ .setDescriptorSetCount( static_cast<uint32_t>( vertexShader->GetDescriptorSetLayouts().size() ) ) );
auto& gpuManager = gr.GetDeviceMemoryManager();
auto bufferMemory = test_gpu_memory_manager( gr, gpuManager, vertexBuffer );
vertexBuffer->BindMemory( bufferMemory );
- auto ptr = static_cast<uint8_t*>(bufferMemory->Map());
- std::copy( reinterpret_cast<const uint8_t*>(VERTICES), reinterpret_cast<const uint8_t*>(VERTICES)+(sizeof(float)*9), ptr);
+ auto ptr = static_cast<uint8_t*>( bufferMemory->Map() );
+ std::copy( reinterpret_cast<const uint8_t*>( VERTICES ),
+ reinterpret_cast<const uint8_t*>( VERTICES ) + ( sizeof( float ) * 9 ),
+ ptr );
bufferMemory->Unmap();
auto pipeline = create_pipeline( gr, vertexShader, fragmentShader );
auto cmdDraw = commandPool->NewCommandBuffer( false );
// begin recording
- cmdDraw->Begin( vk::CommandBufferUsageFlagBits::eRenderPassContinue);
+ cmdDraw->Begin( vk::CommandBufferUsageFlagBits::eRenderPassContinue );
// vertex buffer
cmdDraw->BindVertexBuffer( 0, vertexBuffer, 0 );
// finish
cmdDraw->End();
-
-
bool running = true;
while( running )
auto cmdbuf = gr.GetSurface( fbid ).GetCurrentCommandBuffer();
// get command buffer for current frame and execute the draw call
- cmdbuf->ExecuteCommands( { cmdDraw } );
-
+ cmdbuf->ExecuteCommands( {cmdDraw} );
graphics->PostRender( fbid );
}
return 0;
}
-}
+} // namespace VulkanTest
int main()
{
surface.AcquireNextImage();
}
+Dali::Graphics::API::Controller& Graphics::GetController()
+{
+ auto ptr = this;
+ return *reinterpret_cast<Dali::Graphics::API::Controller*>(ptr);
+}
+
/*
* Postrender
*/
{
namespace Graphics
{
-
+namespace API
+{
+class Controller;
+}
// frame buffer id
using FBID = uint32_t;
*/
void PostRender( Dali::Graphics::FBID framebufferId = 0u );
+ /**
+ * Returns controller object
+ * @return
+ */
+ Dali::Graphics::API::Controller& GetController();
+
// this function is used only by the standalone test
template <class T>
T& GetImplementation() const
renderController,
*mRenderManager,
renderQueue,
- *mRenderTaskProcessor );
+ *mRenderTaskProcessor,
+ graphics );
mRenderManager->SetShaderSaver( *mUpdateManager );
$(internal_src_dir)/update/controllers/scene-controller-impl.cpp \
$(internal_src_dir)/update/gestures/pan-gesture-profiling.cpp \
$(internal_src_dir)/update/gestures/scene-graph-pan-gesture.cpp \
+ $(internal_src_dir)/update/graphics/graphics-algorithms.cpp \
$(internal_src_dir)/update/queue/update-message-queue.cpp \
$(internal_src_dir)/update/manager/render-instruction-processor.cpp \
$(internal_src_dir)/update/manager/render-task-processor.cpp \
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/update/graphics/graphics-algorithms.h>
+
+// EXTERNAL INCLUDES
+
+#include <dali/graphics-api/graphics-api-controller.h>
+#include <dali/graphics-api/graphics-api-frame.h>
+#include <dali/graphics-api/graphics-api-render-command.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/common/buffer-index.h>
+#include <dali/internal/render/common/render-instruction-container.h>
+#include <dali/internal/render/common/render-instruction.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+namespace
+{
+void SubmitRenderItemList( Graphics::API::Controller& graphics,
+ Graphics::API::Frame& frame,
+ BufferIndex bufferIndex,
+ Graphics::API::RenderCommandBuilder& commandBuilder,
+ Matrix viewProjection,
+ const RenderList& renderItemList )
+{
+ // TODO: @todo Set shaders and other properties
+ //commandBuilder.Set( );
+
+ // TODO: @todo Clipping...
+
+ auto numberOfRenderItems = renderItemList.Count();
+
+ using DataT = struct
+ {
+ Matrix world;
+ Vector4 color;
+ Vector3 size;
+ } __attribute__((aligned(16)));
+
+ auto uniformBuffer = graphics.CreateBuffer<DataT>( numberOfRenderItems );
+ auto data = uniformBuffer->GetData();
+ for( auto i = 0u; i < numberOfRenderItems; ++i )
+ {
+ auto& item = renderItemList.GetItem( i );
+ Matrix::Multiply( data[i].world, item.mModelMatrix, viewProjection );
+ data[i].color = item.mNode->GetWorldColor( bufferIndex );
+ data[i].size = item.mSize;
+ }
+ commandBuilder.Set( Graphics::API::PrimitiveCount{numberOfRenderItems} );
+
+ auto buffers = std::vector<Graphics::API::BufferInfo>{};
+ buffers.emplace_back(std::move(uniformBuffer));
+
+ commandBuilder.Set( Graphics::API::BufferList{std::move(buffers)} );
+ // auto cmd = commandBuilder.Build();
+ // graphics.SubmitCommand( std::move(cmd) );
+}
+
+void SubmitInstruction( Graphics::API::Controller& graphics,
+ Graphics::API::Frame& frame,
+ BufferIndex bufferIndex,
+ RenderInstruction& instruction )
+{
+ using namespace Graphics::API;
+
+ // Create constant buffer with static uniforms: view matrix, progrjection matrix
+
+ // TODO: @todo: buffer for constant uniforms
+ /*
+ auto contantUniforms = BuildBuffer<ProjectionMatrix, ViewMatrix>();
+ constantUniforms["uProjection"] = projectionMatrix;
+ constantUniforms["uViewMatrix"] = viewMatrix;
+ */
+
+ const Matrix* viewMatrix = instruction.GetViewMatrix( bufferIndex );
+ const Matrix* projectionMatrix = instruction.GetProjectionMatrix( bufferIndex );
+ Matrix viewProjection;
+ Matrix::Multiply( viewProjection, *viewMatrix, *projectionMatrix );
+
+ auto commandBuilder = RenderCommandBuilder{};
+
+ auto numberOfRenderLists = instruction.RenderListCount();
+ for( auto i = 0u; i < numberOfRenderLists; ++i )
+ {
+ SubmitRenderItemList(
+ graphics, frame, bufferIndex, commandBuilder, viewProjection, *instruction.GetRenderList( i ) );
+ }
+}
+} // namespace
+
+void SubmitRenderInstructions( Graphics::API::Controller& graphics,
+ RenderInstructionContainer& renderInstructions,
+ BufferIndex bufferIndex )
+{
+ auto frame = Graphics::API::Frame{};
+ graphics.BeginFrame();
+
+ auto numberOfInstructions = renderInstructions.Count( bufferIndex );
+ for( size_t i = 0; i < numberOfInstructions; ++i )
+ {
+ RenderInstruction& instruction = renderInstructions.At( bufferIndex, i );
+
+ SubmitInstruction( graphics, frame, bufferIndex, instruction );
+ }
+
+ graphics.EndFrame( );
+}
+
+} // namespace SceneGraph
+} // namespace Internal
+} // namespace Dali
--- /dev/null
+#ifndef DALI_INTERNAL_GRAPHICS_ALGORITHMS_H
+#define DALI_INTERNAL_GRAPHICS_ALGORITHMS_H
+
+/*
+ * Copyright (c) 2018 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/graphics-api/graphics-api-controller.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/render/common/render-instruction-container.h>
+#include <dali/internal/common/buffer-index.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+void SubmitRenderInstructions( Graphics::API::Controller& graphics,
+ SceneGraph::RenderInstructionContainer& renderInstructions,
+ BufferIndex bufferIndex );
+
+} // namespace SceneGraph
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_GRAPHICS_ALGORITHMS_H
\ No newline at end of file
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
// CLASS HEADER
#include <dali/internal/update/manager/update-manager.h>
+// EXTERNAL INCLUDES
+#include <dali/graphics/graphics-controller.h>
+
// INTERNAL INCLUDES
#include <dali/public-api/common/stage.h>
-#include <dali/devel-api/common/owner-container.h>
-#include <dali/devel-api/threading/mutex.h>
#include <dali/integration-api/core.h>
-#include <dali/integration-api/render-controller.h>
-#include <dali/internal/common/shader-data.h>
#include <dali/integration-api/debug.h>
+#include <dali/integration-api/render-controller.h>
+#include <dali/integration-api/graphics/graphics.h>
+#include <dali/devel-api/common/owner-container.h>
+#include <dali/devel-api/threading/mutex.h>
#include <dali/internal/common/core-impl.h>
#include <dali/internal/common/message.h>
-
+#include <dali/internal/common/shader-data.h>
+#include <dali/internal/event/animation/animation-playlist.h>
#include <dali/internal/event/common/notification-manager.h>
#include <dali/internal/event/common/property-notification-impl.h>
#include <dali/internal/event/common/property-notifier.h>
#include <dali/internal/event/effects/shader-factory.h>
-#include <dali/internal/event/animation/animation-playlist.h>
-
-#include <dali/internal/update/animation/scene-graph-animator.h>
+#include <dali/internal/render/common/render-instruction-container.h>
+#include <dali/internal/render/common/render-manager.h>
+#include <dali/internal/render/queue/render-queue.h>
+#include <dali/internal/render/shaders/scene-graph-shader.h>
#include <dali/internal/update/animation/scene-graph-animation.h>
+#include <dali/internal/update/animation/scene-graph-animator.h>
#include <dali/internal/update/common/discard-queue.h>
#include <dali/internal/update/common/scene-graph-buffers.h>
#include <dali/internal/update/controllers/render-message-dispatcher.h>
#include <dali/internal/update/controllers/scene-controller-impl.h>
#include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
+#include <dali/internal/update/graphics/graphics-algorithms.h>
#include <dali/internal/update/manager/render-task-processor.h>
#include <dali/internal/update/manager/sorted-layers.h>
+#include <dali/internal/update/manager/transform-manager.h>
#include <dali/internal/update/manager/update-algorithms.h>
#include <dali/internal/update/manager/update-manager-debug.h>
-#include <dali/internal/update/manager/transform-manager.h>
#include <dali/internal/update/nodes/node.h>
#include <dali/internal/update/nodes/scene-graph-layer.h>
#include <dali/internal/update/queue/update-message-queue.h>
-#include <dali/internal/update/render-tasks/scene-graph-render-task.h>
-#include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
#include <dali/internal/update/render-tasks/scene-graph-camera.h>
-
-#include <dali/internal/render/common/render-instruction-container.h>
-#include <dali/internal/render/common/render-manager.h>
-#include <dali/internal/render/queue/render-queue.h>
-#include <dali/internal/render/shaders/scene-graph-shader.h>
-
-#include <dali/graphics/graphics-controller.h>
+#include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
+#include <dali/internal/update/render-tasks/scene-graph-render-task.h>
// Un-comment to enable node tree debug logging
//#define NODE_TREE_LOGGING 1
RenderManager& renderManager,
RenderQueue& renderQueue,
SceneGraphBuffers& sceneGraphBuffers,
- RenderTaskProcessor& renderTaskProcessor )
+ RenderTaskProcessor& renderTaskProcessor,
+ Integration::Graphics::Graphics& graphics )
: renderMessageDispatcher( renderManager, renderQueue, sceneGraphBuffers ),
notificationManager( notificationManager ),
transformManager(),
renderQueue( renderQueue ),
renderInstructions( renderManager.GetRenderInstructionContainer() ),
renderTaskProcessor( renderTaskProcessor ),
+ graphics( graphics ),
backgroundColor( Dali::Stage::DEFAULT_BACKGROUND_COLOR ),
taskList( renderMessageDispatcher ),
systemLevelTaskList( renderMessageDispatcher ),
RenderQueue& renderQueue; ///< Used to queue messages for the next render
RenderInstructionContainer& renderInstructions; ///< Used to prepare the render instructions
RenderTaskProcessor& renderTaskProcessor; ///< Handles RenderTasks and RenderInstrucitons
+ Integration::Graphics::Graphics& graphics; ///< Graphics
Vector4 backgroundColor; ///< The glClear color used at the beginning of each frame.
bool renderTaskWaiting; ///< A REFRESH_ONCE render task is waiting to be rendered
bool renderersAdded; ///< Flag to keep track when renderers have been added to avoid unnecessary processing
+
private:
Impl( const Impl& ); ///< Undefined
Impl& operator=( const Impl& ); ///< Undefined
};
-UpdateManager::UpdateManager( NotificationManager& notificationManager,
- CompleteNotificationInterface& animationFinishedNotifier,
- PropertyNotifier& propertyNotifier,
- DiscardQueue& discardQueue,
- RenderController& controller,
- RenderManager& renderManager,
- RenderQueue& renderQueue,
- RenderTaskProcessor& renderTaskProcessor )
- : mImpl(NULL)
+UpdateManager::UpdateManager( NotificationManager& notificationManager,
+ CompleteNotificationInterface& animationFinishedNotifier,
+ PropertyNotifier& propertyNotifier,
+ DiscardQueue& discardQueue,
+ RenderController& controller,
+ RenderManager& renderManager,
+ RenderQueue& renderQueue,
+ RenderTaskProcessor& renderTaskProcessor,
+ Integration::Graphics::Graphics& graphics )
+: mImpl( new Impl( notificationManager,
+ animationFinishedNotifier,
+ propertyNotifier,
+ discardQueue,
+ controller,
+ renderManager,
+ renderQueue,
+ mSceneGraphBuffers,
+ renderTaskProcessor,
+ graphics) )
{
- mImpl = new Impl( notificationManager,
- animationFinishedNotifier,
- propertyNotifier,
- discardQueue,
- controller,
- renderManager,
- renderQueue,
- mSceneGraphBuffers,
- renderTaskProcessor );
-
-
- Dali::Graphics::Controller gfxController;
}
UpdateManager::~UpdateManager()
{
- delete mImpl;
+ // required due to unique_ptr to mImpl
}
+
void UpdateManager::InstallRoot( OwnerPointer<Layer>& layer, bool systemLevel )
{
DALI_ASSERT_DEBUG( layer->IsLayer() );
//reset the update buffer index and make sure there is enough room in the instruction container
if( mImpl->renderersAdded )
{
- mImpl->renderInstructions.ResetAndReserve( bufferIndex,
- mImpl->taskList.GetTasks().Count() + mImpl->systemLevelTaskList.GetTasks().Count() );
+ mImpl->renderInstructions.ResetAndReserve(bufferIndex,
+ mImpl->taskList.GetTasks().Count() +
+ mImpl->systemLevelTaskList.GetTasks().Count());
if ( NULL != mImpl->root )
{
isRenderingToFbo );
}
}
+ // generate graphics objects
+ SubmitRenderInstructions( mImpl->graphics.GetController(), mImpl->renderInstructions, bufferIndex );
}
}
#define DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
*
*/
+//EXTERNAL INCLUDES
+#include <iostream>
+#include <memory>
+
// INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/common/vector-wrapper.h>
#include <dali/internal/common/message.h>
-#include <dali/internal/common/type-abstraction-enums.h>
#include <dali/internal/common/shader-saver.h>
+#include <dali/internal/common/type-abstraction-enums.h>
#include <dali/internal/event/common/event-thread-services.h>
+#include <dali/internal/event/rendering/texture-impl.h>
+#include <dali/internal/render/renderers/render-property-buffer.h>
+#include <dali/internal/render/shaders/scene-graph-shader.h> // for OwnerPointer< Shader >
#include <dali/internal/update/animation/scene-graph-animation.h>
#include <dali/internal/update/common/scene-graph-buffers.h>
#include <dali/internal/update/common/scene-graph-property-notification.h>
+#include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
#include <dali/internal/update/nodes/node.h>
#include <dali/internal/update/nodes/scene-graph-layer.h>
-#include <dali/internal/update/rendering/scene-graph-renderer.h> // for OwnerPointer< Renderer >
-#include <dali/internal/update/rendering/scene-graph-texture-set.h> // for OwnerPointer< TextureSet >
-#include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
#include <dali/internal/update/render-tasks/scene-graph-camera.h>
-#include <dali/internal/render/shaders/scene-graph-shader.h> // for OwnerPointer< Shader >
-#include <dali/internal/render/renderers/render-property-buffer.h>
-#include <dali/internal/event/rendering/texture-impl.h>
+#include <dali/internal/update/rendering/scene-graph-renderer.h> // for OwnerPointer< Renderer >
+#include <dali/internal/update/rendering/scene-graph-texture-set.h> // for OwnerPointer< TextureSet >
namespace Dali
{
{
class GlSyncAbstraction;
class RenderController;
-
+namespace Graphics
+{
+class Graphics;
+}
} // namespace Integration
namespace Internal
Integration::RenderController& controller,
RenderManager& renderManager,
RenderQueue& renderQueue,
- RenderTaskProcessor& renderTaskProcessor );
+ RenderTaskProcessor& renderTaskProcessor,
+ Dali::Integration::Graphics::Graphics& graphics);
/**
* Destructor.
SceneGraphBuffers mSceneGraphBuffers;
struct Impl;
- Impl* mImpl;
+ std::unique_ptr<Impl> mImpl;
};