bool Exists() const
{
+ if( !mOwner )
+ {
+ return false;
+ }
return GetOwner().Contains(mHandle);
}
// 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-shader-details.h>
#include <dali/graphics-api/graphics-api-shader-factory.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-buffer.h>
#include <dali/graphics-api/graphics-api-buffer-factory.h>
/**
* @brief Create a new object
*/
- virtual Accessor<TextureSet> CreateTextureSet( const BaseFactory<TextureSet>& factory ) = 0;
-
- /**
- * @brief Create a new object
- */
- virtual Accessor<DynamicBuffer> CreateDynamicBuffer( const BaseFactory<DynamicBuffer>& factory ) = 0;
-
- /**
- * @brief Create a new object
- */
virtual Accessor<Buffer> CreateBuffer( const BaseFactory<Buffer>& factory ) = 0;
/**
* @brief Create a new object
*/
- virtual Accessor<StaticBuffer> CreateStaticBuffer( const BaseFactory<StaticBuffer>& factory ) = 0;
-
- /**
- * @brief Create a new object
- */
virtual Accessor<Sampler> CreateSampler( const BaseFactory<Sampler>& factory ) = 0;
/**
virtual BufferFactory& GetBufferFactory() const = 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 alAllocates render command ( depends on implementation );
* @return
*/
*/
Controller() = default;
-
-
/**
* @brief create an element for the given number of elements and element size
*/
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_DYNAMIC_BUFFER_H
-#define DALI_GRAPHICS_API_DYNAMIC_BUFFER_H
-
-/*
- * Copyright (c) 2016 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 DynamicBuffer types in the graphics API.
- */
-class DynamicBuffer
-{
-public:
- // not copyable
- DynamicBuffer(const DynamicBuffer&) = delete;
- DynamicBuffer& operator=(const DynamicBuffer&) = delete;
-
- virtual ~DynamicBuffer() = default;
-
-protected:
- // derived types should not be moved direcly to prevent slicing
- DynamicBuffer(DynamicBuffer&&) = default;
- DynamicBuffer& operator=(DynamicBuffer&&) = default;
-
- /**
- * Objects of this type should not directly.
- */
- DynamicBuffer() = default;
-};
-
-} // namespace API
-} // namespace Graphics
-} // namespace Dali
-
-#endif // DALI_GRAPHICS_API_DYNAMIC_BUFFER_H
+++ /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
+++ /dev/null
-#ifndef DALI_GRAPHICS_API_GENERIC_BUFFER_H
-#define DALI_GRAPHICS_API_GENERIC_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.
- *
- */
-
-#include <cstddef>
-#include <memory>
-
-namespace Dali
-{
-namespace Graphics
-{
-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;
-
- char* GetDataBase()
- {
- return mData.get();
- }
-
-protected:
- // 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 T>
-class GenericBuffer final : public GenericBufferBase
-{
-public:
- GenericBuffer( size_t numberOfElements, std::unique_ptr<char>&& data )
- : GenericBufferBase( numberOfElements * sizeof( T ), std::move( data ) ){};
-
- virtual ~GenericBuffer() = default;
-
- GenericBuffer( GenericBuffer&& ) = default;
- GenericBuffer& operator=( GenericBuffer&& ) = default;
-
- // not copyable
- GenericBuffer( const GenericBuffer& ) = delete;
- GenericBuffer& operator=( const GenericBuffer& ) = delete;
-
- T* GetData()
- {
- return reinterpret_cast<T*>( GenericBufferBase::GetDataBase() );
- }
-};
-
-} // namespace API
-} // namespace Graphics
-} // namespace Dali
-
-#endif // DALI_GRAPHICS_API_GENERIC_BUFFER_H
#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>
#include <dali/graphics-api/graphics-api-shader-details.h>
#include <dali/graphics-api/graphics-api-accessor.h>
#include <dali/graphics-api/graphics-api-framebuffer.h>
class Texture;
class Buffer;
class Sampler;
+class Pipeline;
+
/**
* @brief Interface class for RenderCommand types in the graphics API.
*/
struct RenderState
{
+ struct BlendState
+ {
+ bool blendingEnabled { false };
+ };
+
RenderState() = default;
Accessor<Shader> shader { nullptr };
+ BlendState blendState {};
RenderState& SetShader( Accessor<Shader> value )
{
shader = value;
return *this;
}
+
+ RenderState& SetBlendState( BlendState value )
+ {
+ blendState = value;
+ return *this;
+ }
+
void* pNext{ nullptr };
};
mRenderTargetBinding(),
mDrawCommand(),
mPushConstantsBindings(),
- mRenderState()
+ mRenderState(),
+ mPipeline( nullptr )
{
}
return *this;
}
- RenderCommand& BindRenderState( RenderState&& renderState )
+ RenderCommand& BindRenderState( RenderState& renderState )
{
mRenderState = renderState;
return *this;
}
+ RenderCommand& BindRenderTarget( const RenderTargetBinding& binding )
+ {
+ mRenderTargetBinding = binding;
+ return *this;
+ }
+
+ RenderCommand& BindRenderTarget( RenderTargetBinding&& binding )
+ {
+ mRenderTargetBinding = std::move(binding);
+ return *this;
+ }
+
RenderCommand& Draw( DrawCommand&& drawCommand )
{
mDrawCommand = drawCommand;
return *this;
}
+ RenderCommand& BindPipeline( const Accessor<Pipeline>& pipeline )
+ {
+ mPipeline = pipeline;
+ return *this;
+ }
+
static std::vector<VertexAttributeBufferBinding> NewVertexAttributeBufferBindings()
{
return std::vector<VertexAttributeBufferBinding>{};
return mRenderState;
}
+ Accessor<Pipeline> GetPipeline() const
+ {
+ return mPipeline;
+ }
+
protected:
std::vector<VertexAttributeBufferBinding> mVertexBufferBindings;
DrawCommand mDrawCommand;
std::vector<PushConstantsBinding> mPushConstantsBindings;
RenderState mRenderState;
+ Accessor<Pipeline> mPipeline;
};
-using RenderCommandBuilder = Utility::Builder<RenderCommand>;
-
} // namespace API
} // namespace Graphics
} // namespace Dali
#endif // DALI_GRAPHICS_API_RENDER_COMMAND_H
+
+
+/**
+ * @brief Interface class for RenderCommand types in the graphics API.
+ *
+ * @startuml
+ *
+ * skinparam defaultFontName Ubuntu Mono
+ * class RenderCommand {
+ * -- protected --
+ * #VertexAttributeBufferBinding[] mVertexBufferBindings
+ * #UniformBufferBinding[] mUniformBufferBindings
+ * #TextureBinding[] mTextureBindings
+ * #SamplerBinding[] mSamplerBindings
+ * #IndexBufferBinding mIndexBufferBinding
+ * #RenderTargetBinding mRenderTargetBinding
+ * #DrawCommand mDrawCommand
+ * #PushConstantsBinding[] mPushConstantsBindings
+ * #RenderState mRenderState
+ *
+ * -- public API --
+ * +RenderCommand& BindVertextBuffers()
+ * +RenderCommand& BindUniformBuffers()
+ * +RenderCommand& BindTextures()
+ * +RenderCommand& BindSamplers()
+ * +RenderCommand& PushConstants()
+ * +RenderCommand& BindRenderState()
+ * +RenderCommand& Draw()
+ * -- static API ( helper functions )--
+ * {static} NewVertexAttributeBufferBindings()
+ * {static} NewVertexAttributeBufferBindings()
+ * {static} NewVertexAttributeBufferBindings()
+ * {static} NewTextureBindings()
+ * {static} NewPushConstantsBindings()
+ * }
+ *
+ * class VertexAttributeBufferBinding {
+ * Accessor<Buffer> buffer
+ * uint32_t location
+ * uint32_t offset
+ * uint32_t stride
+ * InputAttributeRate rate
+ * void* pNext
+ * }
+ *
+ * class UniformBufferBinding {
+ * #Accessor<Buffer> buffer
+ * #uint32_t offset
+ * #uint32_t dataSize
+ * #uint32_t binding
+ * #void* pNext
+ * }
+ *
+ class IndexBufferBinding {
+ #Accessor<Buffer> buffer
+ #uint32_t offset
+ #IndexType type
+ #void* pNext
+ }
+
+ class RenderTargetBinding {
+ #Accessor<Framebuffer> framebuffer
+ #std::vector<Framebuffer::ClearColor> clearColors
+ #Framebuffer::DepthStencilClearColor dsClearColor
+ #void* pNext
+ }
+
+ class DrawCommand {
+ #DrawType drawType;
+ #uint32_t firstVertex
+ #uint32_t firstIndex
+ #uint32_t vertexCount
+ #uint32_t indicesCount
+ #uint32_t firstInstance
+ #uint32_t instanceCount
+ #void* pNext
+ }
+
+ class PushConstantsBinding {
+ #void* data
+ #uint32_t size
+ #uint32_t binding
+ #void* pNext
+ }
+
+ class RenderState {
+ #Accessor<Shader> shader
+ #void* pNext
+ }
+
+ class TextureBinding {
+ #Accessor<Texture> texture
+ #Accessor<Sampler> sampler
+ #uint32_t binding
+ #void* pNext
+ }
+
+ class SamplerBinding {
+ #Accessor<Sampler> sampler
+ #uint32_t binding
+ #void* pNext
+ }
+
+ note as RenderStateWIP
+ Other render states like
+ blending etc. should be added
+ as public fields of this structure.
+ end note
+
+ RenderStateWIP .. RenderState
+
+ * note as N1
+ * Each state is described as POD
+ * structure which is a Vulkan
+ * approach.
+ * end note
+ *
+ * note as N2
+ * Field pNext may be used by the
+ * implementation to pass additional
+ * data.
+ * end note
+ *
+ * N2 .. VertexAttributeBufferBinding::pNext
+ * N1 .. VertexAttributeBufferBinding
+ * N1 .. UniformBufferBinding
+ * N1 .. IndexBufferBinding
+ * N1 .. RenderTargetBinding
+ *
+
+ *
+ * RenderCommand *-right- VertexAttributeBufferBinding
+ * RenderCommand *-right- UniformBufferBinding
+ * RenderCommand *-left- IndexBufferBinding
+ * RenderCommand *-left- RenderTargetBinding
+ * RenderCommand *-up- RenderState
+ * RenderCommand *-up- DrawCommand
+ * RenderCommand *-down- PushConstantsBinding
+ * RenderCommand *-down- SamplerBinding
+ * RenderCommand *-down- TextureBinding
+ * @enduml
+ */
\ No newline at end of file
+++ /dev/null
-#ifndef DALI_GRAPHICS_API_RENDER_ITEM_LIST_H
-#define DALI_GRAPHICS_API_RENDER_ITEM_LIST_H
-
-/*
- * Copyright (c) 2017 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 Class that represents a list of RenderItems
- */
-class RenderItemList
-{
-public:
- template< typename Structure >
- void CreateInstanceBuffer();
-
- // not copyable
- RenderItemList(const RenderItemList&) = delete;
- RenderItemList& operator=(const RenderItemList&) = delete;
-
- virtual ~RenderItemList() = default;
-
-protected:
- // derived types should not be moved direcly to prevent slicing
- RenderItemList(RenderItemList&&) = default;
- RenderItemList& operator=(RenderItemList&&) = default;
-
- /**
- * Objects of this type should not directly.
- */
- RenderItemList() = default;
-};
-
-} // namespace API
-} // namespace Graphics
-} // namespace Dali
-
-#endif // DALI_GRAPHICS_API_RENDER_ITEM_LIST_H
+++ /dev/null
-#ifndef DALI_GRAPHICS_API_RENDER_LIST_H
-#define DALI_GRAPHICS_API_RENDER_LIST_H
-
-/*
- * Copyright (c) 2016 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 RenderList types in the graphics API.
- */
-class RenderList
-{
-public:
- using Handle = size_t;
-
- virtual void SetRenderItemData(size_t index) = 0;
-
- // not copyable
- RenderList(const RenderList&) = delete;
- RenderList& operator=(const RenderList&) = delete;
-
- virtual ~RenderList() = default;
-
-protected:
- // derived types should not be moved direcly to prevent slicing
- RenderList(RenderList&&) = default;
- RenderList& operator=(RenderList&&) = default;
-
- /**
- * Objects of this type should not directly.
- */
- RenderList() = default;
-};
-
-} // namespace API
-} // namespace Graphics
-} // namespace Dali
-
-#endif // DALI_GRAPHICS_API_RENDER_LIST_H
+++ /dev/null
-#ifndef DALI_GRAPHICS_API_STATIC_BUFFER_H
-#define DALI_GRAPHICS_API_STATIC_BUFFER_H
-
-/*
- * Copyright (c) 2016 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 Texture types in the graphics API.
- */
-class StaticBuffer
-{
-public:
- // not copyable
- StaticBuffer(const StaticBuffer&) = delete;
- StaticBuffer& operator=(const StaticBuffer&) = delete;
-
- virtual ~StaticBuffer() = default;
-
-protected:
- // derived types should not be moved directly to prevent slicing
- StaticBuffer(StaticBuffer&&) = default;
- StaticBuffer& operator=(StaticBuffer&&) = default;
-
- /**
- * Objects of this type should not directly.
- */
- StaticBuffer() = default;
-};
-
-} // namespace API
-} // namespace Graphics
-} // namespace Dali
-
-#endif // DALI_GRAPHICS_API_STATIC_BUFFER_H
// texture color formats
RGBA8,
+ L8,
ETC2_RGBA8,
// compressed color formats
+++ /dev/null
-#ifndef DALI_GRAPHICS_API_TEXTURE_SET_H
-#define DALI_GRAPHICS_API_TEXTURE_SET_H
-
-/*
- * Copyright (c) 2016 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.
- *
- */
-
-#include <dali/graphics-api/graphics-api-texture.h>
-
-namespace Dali
-{
-namespace Graphics
-{
-namespace API
-{
-
-/**
- * @brief Interface class for TextureSet types in the graphics API.
- */
-class TextureSet
-{
-public:
- virtual void AddTexture(const Accessor< Texture >& texture) = 0;
-
- // not copyable
- TextureSet(const TextureSet&) = delete;
- TextureSet& operator=(const TextureSet&) = delete;
-
- virtual ~TextureSet() = default;
-
-protected:
- // derived types should not be moved direcly to prevent slicing
- TextureSet(TextureSet&&) = default;
- TextureSet& operator=(TextureSet&&) = default;
-
- /**
- * Objects of this type should not directly.
- */
- TextureSet() = default;
-};
-
-} // namespace API
-} // namespace Graphics
-} // namespace Dali
-
-#endif // DALI_GRAPHICS_API_TEXTURE_SET_H
+++ /dev/null
-#ifndef DALI_GRAPHICS_CONTROLLER_H
-#define DALI_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.
- *
- */
-
-#include <dali/graphics-api/graphics-api-controller.h>
-#include <dali/graphics/graphics-object-owner.h>
-
-namespace Dali
-{
-namespace Graphics
-{
-
-/**
- * @brief Controller implementation of the graphics API
- */
-class Controller : public API::Controller
-{
-public:
- virtual API::Accessor< API::Shader > CreateShader(
- const API::BaseFactory< API::Shader >& factory) override;
-
- virtual API::Accessor< API::Texture > CreateTexture(
- const API::BaseFactory< API::Texture >& factory) override;
-
- virtual API::Accessor< API::TextureSet > CreateTextureSet(
- const API::BaseFactory< API::TextureSet >& factory) override;
-
- virtual API::Accessor< API::DynamicBuffer > CreateDynamicBuffer(
- const API::BaseFactory< API::DynamicBuffer >& factory) override;
-
- virtual API::Accessor< API::StaticBuffer > CreateStaticBuffer(
- const API::BaseFactory< API::StaticBuffer >& factory) override;
-
- virtual API::Accessor< API::Sampler > CreateSampler(
- const API::BaseFactory< API::Sampler >& factory) override;
-
- virtual API::Accessor< API::Framebuffer > CreateFramebuffer(
- const API::BaseFactory< API::Framebuffer >& factory) override;
-
- virtual void GetRenderItemList() override;
-
-public:
- Controller();
-
- Controller(const Controller&) = delete;
- Controller& operator=(const Controller&) = delete;
-
- Controller(Controller&&);
- Controller& operator=(Controller&&) = default;
-
- ~Controller() override;
-
-protected:
- ObjectOwner< API::Shader > mShaders;
- ObjectOwner< API::Texture > mTextures;
- ObjectOwner< API::TextureSet > mTextureSets;
- ObjectOwner< API::DynamicBuffer > mDynamicBuffers;
- ObjectOwner< API::StaticBuffer > mStaticBuffers;
- ObjectOwner< API::Sampler > mSamplers;
- ObjectOwner< API::Framebuffer > mFramebuffers;
-};
-
-} // namespace Graphics
-} // namespace Dali
-
-#endif // DALI_GRAPHICS_CONTROLLER_H
auto vertexShader = shader.GetShader(vk::ShaderStageFlagBits::eVertex);
auto fragmentShader = shader.GetShader(vk::ShaderStageFlagBits::eFragment);
- auto pipelineRef = pipelineCache.GetPipeline({vertexShader, fragmentShader, {}});
+ auto pipelineRef = pipelineCache.GetPipeline({vertexShader, fragmentShader, renderState.blendState, {}});
if (!pipelineRef)
{
std::vector<vk::VertexInputBindingDescription> bindingDescriptions{};
uint32_t currentBuffer{0xffffffff};
- for (auto &&vb : GetVertexBufferBindings())
+ if( !attribs.empty() && attribs.size() == GetVertexBufferBindings().size() )
{
- if (currentBuffer != vb.buffer
- .GetHandle())
+ for (auto &&vb : GetVertexBufferBindings())
{
- bindingDescriptions.emplace_back(vk::VertexInputBindingDescription{}
- .setBinding(bindingIndex)
- .setInputRate(vb.rate == API::RenderCommand::InputAttributeRate::PER_VERTEX
- ? vk::VertexInputRate::eVertex
- : vk::VertexInputRate::eInstance)
- .setStride(vb.stride));
- bindingIndex++;
- currentBuffer = Vulkan::U32(vb.buffer
- .GetHandle());
+ if (currentBuffer != vb.buffer
+ .GetHandle())
+ {
+ bindingDescriptions.emplace_back(vk::VertexInputBindingDescription{}
+ .setBinding(bindingIndex)
+ .setInputRate(
+ vb.rate == API::RenderCommand::InputAttributeRate::PER_VERTEX
+ ? vk::VertexInputRate::eVertex
+ : vk::VertexInputRate::eInstance)
+ .setStride(vb.stride));
+ bindingIndex++;
+ currentBuffer = Vulkan::U32(vb.buffer
+ .GetHandle());
+ }
+
+
+ attributeDescriptions.emplace_back(vk::VertexInputAttributeDescription{}
+ .setBinding(bindingDescriptions.back()
+ .binding)
+ .setFormat(attribs[vb.location].format)
+ .setOffset(vb.offset));
}
-
- attributeDescriptions.emplace_back(vk::VertexInputAttributeDescription{}
- .setBinding(bindingDescriptions.back()
- .binding)
- .setFormat(attribs[vb.location].format)
- .setOffset(vb.offset));
+ }
+ else // incompatible pipeline
+ {
+ mUpdateFlags = 0;
+ return false;
}
auto vertexInputState = vk::PipelineVertexInputStateCreateInfo{}
pipeline->Compile();
- pipelineCache.AddPipeline(pipeline, Vulkan::PipelineDescription{vertexShader, fragmentShader, dsLayouts});
+ pipelineCache.AddPipeline(pipeline, Vulkan::PipelineDescription{vertexShader, fragmentShader, renderState.blendState, dsLayouts});
pipelineRef = pipeline;
void RenderCommand::UpdateUniformBuffers()
{
uint32_t uboIndex = 0u;
- for( auto&& pc : mPushConstantsBindings )
+ if(!mUboBuffers.empty() && mUboBuffers.size() == mPushConstantsBindings.size())
{
- mUboBuffers[uboIndex++]->WriteKeepMapped( pc.data, 0, pc.size );
+ for (auto &&pc : mPushConstantsBindings)
+ {
+ mUboBuffers[uboIndex++]->WriteKeepMapped(pc.data, 0, pc.size);
+ }
}
}
//@todo support more attachments
//@todo use data from render state
auto blendAttachmentState = vk::PipelineColorBlendAttachmentState{}
- .setBlendEnable( true )
+ .setBlendEnable( vk::Bool32(mRenderState.blendState.blendingEnabled) )
.setColorWriteMask( vk::ColorComponentFlagBits::eR |
vk::ColorComponentFlagBits::eG |
vk::ColorComponentFlagBits::eB |
vk::ColorComponentFlagBits::eA )
.setSrcColorBlendFactor( vk::BlendFactor::eSrcAlpha )
- .setDstColorBlendFactor( vk::BlendFactor::eOneMinusSrc1Alpha )
+ .setDstColorBlendFactor( vk::BlendFactor::eOneMinusSrcAlpha )
.setSrcAlphaBlendFactor( vk::BlendFactor::eOne )
- .setDstAlphaBlendFactor( vk::BlendFactor::eOneMinusSrc1Alpha )
+ .setDstAlphaBlendFactor( vk::BlendFactor::eOneMinusSrcAlpha )
.setColorBlendOp( vk::BlendOp::eAdd )
.setAlphaBlendOp( vk::BlendOp::eAdd );
return mDescriptorSets;
}
+
} // namespace VulkanAPI
} // namespace Graphics
} // namespace Dali
\ No newline at end of file
const Vulkan::PipelineRef& GetPipeline() const;
+
private:
const vk::PipelineColorBlendStateCreateInfo* PrepareColorBlendStateCreateInfo();
auto sizeInBytes = mTextureFactory.GetDataSize();
auto data = mTextureFactory.GetData();
- auto textureRef = Dali::Graphics::Vulkan::Texture::New( mGraphics, U32(size.width), U32(size.height), vk::Format::eR8G8B8A8Unorm );
+ auto format = vk::Format::eR8G8B8A8Unorm;
- // check bpp, if 24bpp convert
- if( sizeInBytes == width*height*3 )
+ if(mTextureFactory.GetFormat() == API::TextureDetails::Format::RGBA8 )
{
-
- auto inData = reinterpret_cast<const uint8_t*>(data);
- auto outData = new uint8_t[width*height*4];
-
- auto outIdx = 0u;
- for( auto i = 0u; i < sizeInBytes; i+= 3 )
+ // check bpp, if 24bpp convert
+ if (sizeInBytes == width * height * 3)
{
- outData[outIdx] = inData[i];
- outData[outIdx+1] = inData[i+1];
- outData[outIdx+2] = inData[i+2];
- outData[outIdx+3] = 0xff;
- outIdx += 4;
+
+ auto inData = reinterpret_cast<const uint8_t *>(data);
+ auto outData = new uint8_t[width * height * 4];
+
+ auto outIdx = 0u;
+ for (auto i = 0u; i < sizeInBytes; i += 3)
+ {
+ outData[outIdx] = inData[i];
+ outData[outIdx + 1] = inData[i + 1];
+ outData[outIdx + 2] = inData[i + 2];
+ outData[outIdx + 3] = 0xff;
+ outIdx += 4;
+ }
+
+ data = outData;
+ sizeInBytes = U32(width * height * 4);
}
- data = outData;
- sizeInBytes = U32(width*height*4);
}
+ else if(mTextureFactory.GetFormat() == API::TextureDetails::Format::L8 )
+ {
+ format = vk::Format::eR8Unorm;
+ }
+
+ auto textureRef = Dali::Graphics::Vulkan::Texture::New( mGraphics,
+ U32(size.width),
+ U32(size.height),
+ format );
+
// Upload data immediately. Will stall the queue :(
textureRef->UploadData( data, sizeInBytes, TextureUploadMode::eImmediate );
// INTERNAL INCLUDES
#include <dali/graphics-api/graphics-api-texture-factory.h>
#include <dali/graphics-api/graphics-api-texture.h>
-#include <dali/graphics/graphics-controller.h>
#include <dali/graphics/vulkan/vulkan-types.h>
#include <dali/graphics/vulkan/vulkan-graphics-texture.h>