Skip to content

Commit

Permalink
Merge "Passing down render target to compile the pipeline" into devel…
Browse files Browse the repository at this point in the history
…/master
  • Loading branch information
DavidIanSteele authored and Gerrit Code Review committed Sep 6, 2024
2 parents c2ab4cb + 467b036 commit 0fdb135
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 20 deletions.
24 changes: 23 additions & 1 deletion dali/graphics-api/graphics-pipeline-create-info.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define DALI_GRAPHICS_PIPELINE_CREATE_INFO_H

/*
* Copyright (c) 2021 Samsung Electronics Co., Ltd.
* Copyright (c) 2024 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.
Expand All @@ -29,6 +29,7 @@ namespace Dali
{
namespace Graphics
{
class RenderTarget;
/**
* @brief Interface class for generating Pipeline types in the graphics API.
*
Expand Down Expand Up @@ -190,6 +191,25 @@ struct PipelineCreateInfo
return *this;
}

/**
* @brief Sets render target that pipeline will be used with
*
* The pipeline must know which render target (this or compatible)
* it will be used with.
*
* It is valid not to set render target but only if device supports
* 'dynamic rendering'. Our current implementation doesn't support it
* but it may in the future.
*
* @param[in] value Pointer to valid RenderTarget objet
* @return reference to this structure
*/
auto& SetRenderTarget(RenderTarget* value)
{
renderTarget = value;
return *this;
}

GraphicsStructureType type{GraphicsStructureType::PIPELINE_CREATE_INFO_STRUCT};
ExtensionCreateInfo* nextExtension{nullptr};

Expand All @@ -203,6 +223,8 @@ struct PipelineCreateInfo
InputAssemblyState* inputAssemblyState{nullptr};
PipelineDynamicStateMask dynamicStateMask{0u};

RenderTarget* renderTarget{nullptr};

const AllocationCallbacks* allocationCallbacks{nullptr};
};

Expand Down
11 changes: 7 additions & 4 deletions dali/internal/render/common/render-algorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,8 @@ inline void RenderAlgorithms::ProcessRenderList(const RenderList&
const Rect<int32_t>& viewport,
const Rect<int>& rootClippingRect,
int orientation,
const Uint16Pair& sceneSize)
const Uint16Pair& sceneSize,
Graphics::RenderTarget* renderTarget)
{
DALI_PRINT_RENDER_LIST(renderList);

Expand Down Expand Up @@ -704,7 +705,7 @@ inline void RenderAlgorithms::ProcessRenderList(const RenderList&
for(auto queue = 0u; queue < MAX_QUEUE; ++queue)
{
// Render the item. It will write into the command buffer everything it has to render
item.mRenderer->Render(secondaryCommandBuffer, bufferIndex, *item.mNode, item.mModelMatrix, item.mModelViewMatrix, viewMatrix, projectionMatrix, item.mScale, item.mSize, !item.mIsOpaque, instruction, queue);
item.mRenderer->Render(secondaryCommandBuffer, bufferIndex, *item.mNode, item.mModelMatrix, item.mModelViewMatrix, viewMatrix, projectionMatrix, item.mScale, item.mSize, !item.mIsOpaque, instruction, renderTarget, queue);
}
}
}
Expand Down Expand Up @@ -757,7 +758,8 @@ void RenderAlgorithms::ProcessRenderInstruction(const RenderInstruction&
const Rect<int32_t>& viewport,
const Rect<int>& rootClippingRect,
int orientation,
const Uint16Pair& sceneSize)
const Uint16Pair& sceneSize,
Graphics::RenderTarget* renderTarget)
{
DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_RENDER_INSTRUCTION_PROCESS", [&](std::ostringstream& oss) { oss << "[" << instruction.RenderListCount() << "]"; });

Expand Down Expand Up @@ -792,7 +794,8 @@ void RenderAlgorithms::ProcessRenderInstruction(const RenderInstruction&
viewport,
rootClippingRect,
orientation,
sceneSize);
sceneSize,
renderTarget);

// Execute command buffer
auto* commandBuffer = renderList->GetCommandBuffer();
Expand Down
19 changes: 7 additions & 12 deletions dali/internal/render/common/render-algorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define DALI_INTERNAL_RENDER_ALGORITHMS_H

/*
* Copyright (c) 2023 Samsung Electronics Co., Ltd.
* Copyright (c) 2024 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.
Expand Down Expand Up @@ -61,6 +61,7 @@ class RenderAlgorithms
* @param[in] rootClippingRect The clipping rectangle
* @param[in] orientation The Scene's surface orientation.
* @param[in] sceneSize The Scene's surface size.
* @param[in] renderTarget The RenderTarget associated with instruction
*/
void ProcessRenderInstruction(const SceneGraph::RenderInstruction& instruction,
BufferIndex bufferIndex,
Expand All @@ -69,7 +70,8 @@ class RenderAlgorithms
const Rect<int32_t>& viewport,
const Rect<int>& rootClippingRect,
int orientation,
const Uint16Pair& sceneSize);
const Uint16Pair& sceneSize,
Graphics::RenderTarget* renderTarget);

/**
* Resets main command buffer (per scene)
Expand All @@ -95,15 +97,6 @@ class RenderAlgorithms
}

private:
/**
* @brief Calculate a 2D AABB (axis aligned bounding box) in screen space.
* The RenderItems dimensions are translated and a Z value of 0 is assumed for this purpose.
* No projection is performed, but rotation on Z is supported.
* @param[in] item The RenderItem to generate an AABB for
* @return The generated AABB in screen space
*/
inline Dali::ClippingBox CalculateScreenSpaceAABB(const Dali::Internal::SceneGraph::RenderItem& item);

/**
* @brief Perform any scissor clipping related operations based on the current RenderItem.
* This includes:
Expand Down Expand Up @@ -155,6 +148,7 @@ class RenderAlgorithms
* @param[in] rootClippingRect The root clipping rectangle
* @param[in] orientation The Scene's surface orientation
* @param[in] sceneSize The Scene's surface size.
* @param[in] renderTarget The render target associated with render instruction
*/
inline void ProcessRenderList(const Dali::Internal::SceneGraph::RenderList& renderList,
BufferIndex bufferIndex,
Expand All @@ -166,7 +160,8 @@ class RenderAlgorithms
const Rect<int32_t>& viewport,
const Rect<int>& rootClippingRect,
int orientation,
const Uint16Pair& sceneSize);
const Uint16Pair& sceneSize,
Graphics::RenderTarget* renderTarget);

// Member variables:

Expand Down
3 changes: 2 additions & 1 deletion dali/internal/render/common/render-manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,8 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration::
viewportRect,
clippingRect,
surfaceOrientation,
Uint16Pair(surfaceRect.width, surfaceRect.height));
Uint16Pair(surfaceRect.width, surfaceRect.height),
currentRenderTarget);

Graphics::SyncObject* syncObject{nullptr};
// If the render instruction has an associated render tracker (owned separately)
Expand Down
3 changes: 2 additions & 1 deletion dali/internal/render/renderers/pipeline-cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,8 @@ PipelineResult PipelineCache::GetPipeline(const PipelineCacheQueryInfo& queryInf
.SetVertexInputState(&level0->inputState)
.SetRasterizationState(&level1->rs)
.SetColorBlendState(&level2->colorBlendState)
.SetProgramState(&programState);
.SetProgramState(&programState)
.SetRenderTarget(queryInfo.renderTarget);

// Store a pipeline per renderer per render (renderer can be owned by multiple nodes,
// and re-drawn in multiple instructions).
Expand Down
2 changes: 2 additions & 0 deletions dali/internal/render/renderers/pipeline-cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ struct PipelineCacheQueryInfo
Program* program;
Geometry* geometry;

Graphics::RenderTarget* renderTarget;

bool cameraUsingReflection;

// Blending
Expand Down
5 changes: 4 additions & 1 deletion dali/internal/render/renderers/render-renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ bool Renderer::Render(Graphics::CommandBuffer& comma
const Vector3& size,
bool blend,
const Dali::Internal::SceneGraph::RenderInstruction& instruction,
Graphics::RenderTarget* renderTarget,
uint32_t queueIndex)
{
// Before doing anything test if the call happens in the right queue
Expand Down Expand Up @@ -591,7 +592,7 @@ bool Renderer::Render(Graphics::CommandBuffer& comma
if(program)
{
// Prepare the graphics pipeline. This may either re-use an existing pipeline or create a new one.
auto& pipeline = PrepareGraphicsPipeline(*program, instruction, node, blend);
auto& pipeline = PrepareGraphicsPipeline(*program, instruction, renderTarget, node, blend);

commandBuffer.BindPipeline(pipeline);

Expand Down Expand Up @@ -1062,6 +1063,7 @@ Vector4 Renderer::GetTextureUpdateArea() const noexcept
Graphics::Pipeline& Renderer::PrepareGraphicsPipeline(
Program& program,
const Dali::Internal::SceneGraph::RenderInstruction& instruction,
Graphics::RenderTarget* renderTarget,
const SceneGraph::NodeDataProvider& node,
bool blend)
{
Expand All @@ -1074,6 +1076,7 @@ Graphics::Pipeline& Renderer::PrepareGraphicsPipeline(
queryInfo.blendingOptions = &mBlendingOptions;
queryInfo.alphaPremultiplied = mPremultipliedAlphaEnabled;
queryInfo.cameraUsingReflection = instruction.GetCamera()->GetReflectionUsed();
queryInfo.renderTarget = renderTarget;

queryInfo.GenerateHash();

Expand Down
4 changes: 4 additions & 0 deletions dali/internal/render/renderers/render-renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ class Renderer : public Program::LifecycleObserver
* @param[in] size Size of the render item
* @param[in] blend If true, blending is enabled
* @param[in] instruction. for use case like reflection where CullFace needs to be adjusted
* @param[in] renderTarget render target associated with instruction
* @param[in] queueIndex Index of the render queue
*
* @return True if commands have been added to the command buffer
*/
Expand All @@ -426,6 +428,7 @@ class Renderer : public Program::LifecycleObserver
const Vector3& size,
bool blend,
const Dali::Internal::SceneGraph::RenderInstruction& instruction,
Graphics::RenderTarget* renderTarget,
uint32_t queueIndex);

/**
Expand Down Expand Up @@ -583,6 +586,7 @@ class Renderer : public Program::LifecycleObserver
Graphics::Pipeline& PrepareGraphicsPipeline(
Program& program,
const Dali::Internal::SceneGraph::RenderInstruction& instruction,
Graphics::RenderTarget* renderTarget,
const SceneGraph::NodeDataProvider& node,
bool blend);

Expand Down

0 comments on commit 0fdb135

Please sign in to comment.