return false;
}
+bool TestGraphicsController::GetProgramParameter(Graphics::Program& program, uint32_t parameterId, void* outData )
+{
+ mCallStack.PushCall("GetProgramParameter", "");
+ return false;
+}
+
} // namespace Dali
mSubmitStack.clear();
}
+ /**
+ * @brief Retrieves program parameters
+ *
+ * This function can be used to retrieve data from internal implementation
+ *
+ * @param[in] program Valid program object
+ * @param[in] parameterId Integer parameter id
+ * @param[out] outData Pointer to output memory
+ * @return True on success
+ */
+ bool GetProgramParameter(Graphics::Program& program, uint32_t parameterId, void* outData ) override;
+
public:
mutable TraceCallStack mCallStack;
mutable TraceCallStack mCommandBufferCallStack;
*/
virtual bool PipelineEquals(const Pipeline& pipeline0, const Pipeline& pipeline1) const = 0;
+ /**
+ * @brief Retrieves program parameters
+ *
+ * This function can be used to retrieve data from internal implementation
+ *
+ * @param[in] program Valid program object
+ * @param[in] parameterId Integer parameter id
+ * @param[out] outData Pointer to output memory
+ * @return True on success
+ */
+ virtual bool GetProgramParameter(Graphics::Program& program, uint32_t parameterId, void* outData ) = 0;
+
protected:
/**
* Creates controller
return;
}
- // Get the program to use
- // The program cache owns the Program object so we don't need to worry about this raw allocation here.
- ShaderDataPtr shaderData = mRenderDataProvider->GetShader().GetShaderData();
- Program* program = Program::New(*mProgramCache, shaderData, (shaderData->GetHints() & Dali::Shader::Hint::MODIFIES_GEOMETRY) != 0x0);
-
- if(!program)
- {
- DALI_LOG_ERROR("Failed to get program for shader at address %p.\n", reinterpret_cast<void*>(&mRenderDataProvider->GetShader()));
- return;
- }
-
Graphics::UniquePtr<Graphics::CommandBuffer> commandBuffer = mGraphicsController->CreateCommandBuffer(
Graphics::CommandBufferCreateInfo()
.SetLevel(Graphics::CommandBufferLevel::SECONDARY),
// Create Shader.
// Really, need to have a pipeline cache in implementation.
-
- mLegacyProgram.programId = program->GetProgramId();
+ // Get the program to use
+ // The program cache owns the Program object so we don't need to worry about this raw allocation here.
+ ShaderDataPtr shaderData = mRenderDataProvider->GetShader().GetShaderData();
Dali::Graphics::Shader& vertexShader = mShaderCache->GetShader(
shaderData->GetShaderForPipelineStage(Graphics::PipelineStage::VERTEX_SHADER),
shaderData->GetSourceMode());
std::vector<Graphics::ShaderState> shaderStates{
- Graphics::ShaderState().SetShader(vertexShader).SetPipelineStage(Graphics::PipelineStage::VERTEX_SHADER),
- Graphics::ShaderState().SetShader(fragmentShader).SetPipelineStage(Graphics::PipelineStage::FRAGMENT_SHADER)};
+ Graphics::ShaderState()
+ .SetShader(vertexShader)
+ .SetPipelineStage(Graphics::PipelineStage::VERTEX_SHADER),
+ Graphics::ShaderState()
+ .SetShader(fragmentShader)
+ .SetPipelineStage(Graphics::PipelineStage::FRAGMENT_SHADER)};
+
auto createInfo = Graphics::ProgramCreateInfo();
createInfo.SetShaderState(shaderStates);
- mGraphicsProgram = mGraphicsController->CreateProgram(createInfo, nullptr);
+ mGraphicsProgram = mGraphicsController->CreateProgram(createInfo, std::move(mGraphicsProgram));
+ Program* program = Program::New(*mProgramCache,
+ shaderData,
+ *mGraphicsController,
+ *mGraphicsProgram,
+ (shaderData->GetHints() & Dali::Shader::Hint::MODIFIES_GEOMETRY) != 0x0);
+
+ if(!program)
+ {
+ DALI_LOG_ERROR("Failed to get program for shader at address %p.\n", reinterpret_cast<void*>(&mRenderDataProvider->GetShader()));
+ return;
+ }
// Temporarily create a pipeline here - this will be used for transporting
// topology, vertex format, attrs, rasterization state
- mGraphicsPipeline = std::move(PrepareGraphicsPipeline(*program, instruction, blend));
+ mGraphicsPipeline = PrepareGraphicsPipeline(*program, instruction, blend, std::move(mGraphicsPipeline));
commandBuffer->BindPipeline(*mGraphicsPipeline.get());
Graphics::UniquePtr<Graphics::Pipeline> Renderer::PrepareGraphicsPipeline(
Program& program,
const Dali::Internal::SceneGraph::RenderInstruction& instruction,
- bool blend)
+ bool blend,
+ Graphics::UniquePtr<Graphics::Pipeline>&& oldPipeline)
{
Graphics::InputAssemblyState inputAssemblyState{};
Graphics::VertexInputState vertexInputState{};
.SetColorBlendState(&colorBlendState)
.SetProgramState(&programState)
.SetNextExtension(&mLegacyProgram),
- nullptr);
+ std::move(oldPipeline));
}
} // namespace Render
Graphics::UniquePtr<Graphics::Pipeline> PrepareGraphicsPipeline(
Program& program,
const Dali::Internal::SceneGraph::RenderInstruction& instruction,
- bool blend);
+ bool blend,
+ Graphics::UniquePtr<Graphics::Pipeline>&& oldPipeline);
private:
Graphics::Controller* mGraphicsController;
return *retval;
}
-void ShaderCache::DestroyGraphicsObjects()
-{
- mItems.clear();
-}
-
} // namespace Render
} // namespace Internal
} // namespace Dali
*/
Dali::Graphics::Shader& GetShader(const std::vector<char> shaderCode, Graphics::PipelineStage stage, Graphics::ShaderSourceMode type);
- /**
- * Destroy any graphics objects owned by this scene graph object
- */
- void DestroyGraphicsObjects();
-
private:
std::vector<Item> mItems;
Dali::Graphics::Controller& mController;
#include <dali/public-api/common/constants.h>
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/common/dali-vector.h>
-
+#include <dali/graphics-api/graphics-program.h>
+#include <dali/graphics-api/graphics-controller.h>
namespace
{
void LogWithLineNumbers(const char* source)
// IMPLEMENTATION
-Program* Program::New(ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry)
+Program* Program::New(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& gfxController, Graphics::Program& gfxProgram, bool modifiesGeometry)
{
- size_t shaderHash = shaderData->GetHashValue();
+ uint32_t programId{0u};
+
+ // Get program id and use it as hash for the cache
+ // in order to maintain current functionality as long as needed
+ gfxController.GetProgramParameter( gfxProgram, 1, &programId );
+
+ size_t shaderHash = programId;
+
Program* program = cache.GetProgram(shaderHash);
if(nullptr == program)
{
// program not found so create it
- program = new Program(cache, shaderData, modifiesGeometry);
+ program = new Program(cache, shaderData, programId, modifiesGeometry);
program->Load();
cache.AddProgram(shaderHash, program);
}
-
return program;
}
+
void Program::Use()
{
if(mLinked)
return mModifiesGeometry;
}
-Program::Program(ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry)
+Program::Program(ProgramCache& cache, Internal::ShaderDataPtr shaderData, uint32_t programId, bool modifiesGeometry)
: mCache(cache),
mGlAbstraction(mCache.GetGlAbstraction()),
mProjectionMatrix(nullptr),
// reset values
ResetAttribsUniformCache();
+
+ mProgramId = programId;
+ mLinked = true;
}
Program::~Program()
void Program::Load()
{
+ // Temporary, exist if program id is already set
+ if(mProgramId)
+ {
+ GetActiveSamplerUniforms();
+ return;
+ }
+
DALI_ASSERT_ALWAYS(nullptr != mProgramData.Get() && "Program data is not initialized");
DALI_ASSERT_DEBUG(mProgramId == 0 && "mProgramId != 0, so about to leak a GL resource by overwriting it.");
void Program::Unload()
{
+ // Bypass when using gfx program
+ if(!mProgramData && mProgramId)
+ {
+ return;
+ }
FreeShaders();
if(this == mCache.GetCurrentProgram())
bool Program::CompileShader(GLenum shaderType, GLuint& shaderId, const char* src)
{
+ // Bypass when using gfx program
+ if(!mProgramData && mProgramId)
+ {
+ return true;
+ }
if(!shaderId)
{
LOG_GL("CreateShader(%d)\n", shaderType);
void Program::Link()
{
+ // Bypass when using gfx program
+ if(!mProgramData && mProgramId)
+ {
+ return;
+ }
LOG_GL("LinkProgram(%d)\n", mProgramId);
CHECK_GL(mGlAbstraction, mGlAbstraction.LinkProgram(mProgramId));
void Program::FreeShaders()
{
+ // Bypass when using gfx program
+ if(!mProgramData && mProgramId)
+ {
+ return;
+ }
if(mVertexShaderId)
{
LOG_GL("DeleteShader(%d)\n", mVertexShaderId);
namespace Dali
{
+namespace Graphics
+{
+class Controller;
+class Program;
+}
class Matrix;
namespace Integration
* @param[in] shaderData A pointer to a data structure containing the program source
* and optionally precompiled binary. If the binary is empty the program bytecode
* is copied into it after compilation and linking)
+ * param[in] gfxController Reference to valid graphics Controller object
+ * param[in] gfxProgram Reference to vali graphics Program object
* @param[in] modifiesGeometry True if the shader modifies geometry
* @return pointer to the program
*/
- static Program* New(ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry);
+ static Program* New(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& gfxController, Graphics::Program& gfxProgram, bool modifiesGeometry);
/**
* Takes this program into use
* Constructor, private so no direct instantiation
* @param[in] cache where the programs are stored
* @param[in] shaderData A smart pointer to a data structure containing the program source and binary
+ * @param[in] programId A GL program id
* @param[in] modifiesGeometry True if the vertex shader changes geometry
*/
- Program(ProgramCache& cache, Internal::ShaderDataPtr shaderData, bool modifiesGeometry);
+ Program(ProgramCache& cache, Internal::ShaderDataPtr shaderData, uint32_t programId, bool modifiesGeometry);
public:
/**