// EXTERNAL INCLUDES
#include <glm/glm.hpp>
#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/update/rendering/scene-graph-property-buffer.h>
#include <dali/internal/update/rendering/scene-graph-shader.h>
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-variable"
-#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
-#pragma GCC diagnostic ignored "-Wunused-function"
-
namespace Dali
{
namespace Internal
{
namespace
{
-Graphics::API::RenderCommand& BuildRenderCommand(
- Graphics::API::Controller& graphics,
- Graphics::API::Frame& frame,
- BufferIndex bufferIndex,
-
- Matrix viewProjection,
- const RenderList& renderItemList,
- Graphics::API::RenderCommand& command
-)
-{
- /*
- // per item/renderer
- //const auto& renderer = renderItemList.GetRenderer(0);
- const auto& item = renderItemList.GetItem(0);
-
- // scenegraph renderer should have complete data
- const auto sgRenderer = item.mNode->GetRendererAt(0);
-
-
- const auto& renderer = *item.mRenderer;
- const auto& dataProviderConst = renderer.GetRenderDataProvider();
- auto& dataProvider = const_cast<RenderDataProvider&>( dataProviderConst );
- const auto& uniformMap = dataProvider.GetUniformMap().GetUniformMap( bufferIndex );
-
- // get resources
- const auto& shader = sgRenderer->GetShader();
- const auto& textures = sgRenderer->GetTextures();
- // todo: samplers
- //const auto& samplers = sgRenderer->Get;
-
-
- // prepare vertex buffers
- const auto& vertexBuffers = sgRenderer->GetGeometry()->GetVertexBuffers();
- std::vector<Graphics::API::RenderCommand::VertexAttributeBufferBinding> vertexAttributeBindings;
- auto attribLocation = 0u;
- auto bindingIndex = 0u;
-
- for( auto&& vertexBuffer : vertexBuffers )
- {
- auto attributeCountInForBuffer = vertexBuffer->GetAttributeCount();
-
- for( auto i = 0u; i < attributeCountInForBuffer; ++i )
- {
- // create binding per attribute
- auto binding = Graphics::API::RenderCommand::VertexAttributeBufferBinding{}
- .SetOffset( (vertexBuffer->GetFormat()->components[i]).offset )
- .SetBinding( bindingIndex )
- .SetBuffer( vertexBuffer->GetGfxObject() )
- .SetInputAttributeRate( Graphics::API::RenderCommand::InputAttributeRate::PER_VERTEX )
- .SetLocation( attribLocation + i )
- .SetStride( vertexBuffer->GetFormat()->size );
-
- vertexAttributeBindings.emplace_back( std::move(binding) );
- }
- }
-
- // prepare uniforms
- auto gfxShader = shader.GetGfxObject();
-
- // find mapped uniforms
-*/
- return command;
-}
static constexpr float CLIP_MATRIX_DATA[] = {
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
void SubmitRenderItemList( Graphics::API::Controller& graphics,
- Graphics::API::Frame& frame,
BufferIndex bufferIndex,
- Graphics::API::RenderCommandBuilder& commandBuilder,
Matrix viewProjection,
RenderInstruction& instruction,
const RenderList& renderItemList )
Matrix::Multiply( vulkanProjectionMatrix, *projectionMatrix, CLIP_MATRIX );
std::vector<Graphics::API::RenderCommand*> commandList;
+
+ // @todo: this should be probably separated ???
+ auto renderTargetBinding = Graphics::API::RenderCommand::RenderTargetBinding{}
+ .SetClearColors( {
+ { instruction.mClearColor.r,
+ instruction.mClearColor.g,
+ instruction.mClearColor.b,
+ instruction.mClearColor.a
+ }});
+
+
for( auto i = 0u; i < numberOfRenderItems; ++i )
{
auto& item = renderItemList.GetItem( i );
auto sgRenderer = item.mNode->GetRendererAt(0);
auto& cmd = sgRenderer->GetGfxRenderCommand();
-
+ if(cmd.GetVertexBufferBindings().empty())
+ {
+ continue;
+ }
+ cmd.BindRenderTarget( renderTargetBinding );
Matrix mvp;
Matrix::Multiply( mvp, item.mModelMatrix, viewProjection );
sgRenderer->WriteUniform( "uModelMatrix", item.mModelMatrix );
}
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, projection 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, *instruction.GetRenderList( i ) );
+ graphics, bufferIndex, viewProjection, instruction, *instruction.GetRenderList( i ) );
}
}
} // namespace
RenderInstructionContainer& renderInstructions,
BufferIndex bufferIndex )
{
- auto frame = Graphics::API::Frame{};
graphics.BeginFrame();
{
RenderInstruction& instruction = renderInstructions.At( bufferIndex, i );
- SubmitInstruction( graphics, frame, bufferIndex, instruction );
+ SubmitInstruction( graphics, bufferIndex, instruction );
}
graphics.EndFrame( );
} // namespace Internal
} // namespace Dali
-#pragma GCC diagnostic pop
}
}
+ // Invalid input attributes!
+ if( mShader->GetGfxObject().Get().GetVertexAttributeLocations().size() != vertexAttributeBindings.size())
+ return;
+
UpdateUniformMap( updateBufferIndex );
auto& shader = mShader->GetGfxObject().Get();
auto textureBindings = Graphics::API::RenderCommand::NewTextureBindings();
auto samplers = shader.GetSamplers();
- for( auto i = 0u; i < mTextureSet->GetTextureCount(); ++i )
+ if( mTextureSet )
{
- auto texture = mTextureSet->GetTexture( i );
- auto gfxTexture = texture->GetGfxObject();
- auto binding = Graphics::API::RenderCommand::TextureBinding{}
- .SetBinding( samplers[i].binding )
- .SetTexture( texture->GetGfxObject() )
- .SetSampler( nullptr );
-
- textureBindings.emplace_back( binding );
+ if(!samplers.empty())
+ {
+ for (auto i = 0u; i < mTextureSet->GetTextureCount(); ++i)
+ {
+
+ auto texture = mTextureSet->GetTexture(i);
+ auto gfxTexture = texture->GetGfxObject();
+ auto binding = Graphics::API::RenderCommand::TextureBinding{}
+ .SetBinding(samplers[i].binding)
+ .SetTexture(texture->GetGfxObject())
+ .SetSampler(nullptr);
+
+ textureBindings.emplace_back(binding);
+ }
+ }
}
// Build render command
const auto& vb = mGeometry->GetVertexBuffers()[0];
//vb->Update()
+
+
+
mGfxRenderCommand->PushConstants( std::move(pushConstantsBindings) );
mGfxRenderCommand->BindVertexBuffers( std::move(vertexAttributeBindings) );
mGfxRenderCommand->BindTextures( std::move(textureBindings) );
- mGfxRenderCommand->BindRenderState( std::move( Graphics::API::RenderCommand::RenderState{}
- .SetShader( mShader->GetGfxObject() ) ) );
+ mGfxRenderCommand->BindRenderState( Graphics::API::RenderCommand::RenderState{}
+ .SetShader( mShader->GetGfxObject() )
+ .SetBlendState( { mBlendMode != BlendMode::OFF }) );
mGfxRenderCommand->Draw( std::move(Graphics::API::RenderCommand::DrawCommand{}
.SetFirstVertex(0u)
.SetDrawType( Graphics::API::RenderCommand::DrawType::VERTEX_DRAW )