auto createInfo = Graphics::ProgramCreateInfo();
createInfo.SetShaderState(shaderStates);
- mGraphicsProgram = mGraphicsController->CreateProgram(createInfo, std::move(mGraphicsProgram));
+ auto graphicsProgram = mGraphicsController->CreateProgram(createInfo, nullptr);
Program* program = Program::New(*mProgramCache,
shaderData,
*mGraphicsController,
- *mGraphicsProgram,
+ std::move(graphicsProgram),
(shaderData->GetHints() & Dali::Shader::Hint::MODIFIES_GEOMETRY) != 0x0);
if(!program)
mUpdateAttributeLocations = true;
}
- auto& reflection = mGraphicsController->GetProgramReflection(*mGraphicsProgram.get());
+ auto& reflection = mGraphicsController->GetProgramReflection(program.GetGraphicsProgram());
/**
* Bind Attributes
inputAssemblyState.SetTopology(mGeometry->GetTopology());
// Get the program
- programState.SetProgram(*mGraphicsProgram.get());
+ programState.SetProgram(program.GetGraphicsProgram());
Graphics::RasterizationState rasterizationState{};
ProgramCache* mProgramCache{};
Render::ShaderCache* mShaderCache{};
- Graphics::UniquePtr<Graphics::Program> mGraphicsProgram{}; ///< The graphics program. (Cached implementation)
Graphics::UniquePtr<Graphics::Pipeline> mGraphicsPipeline{}; ///< The graphics pipeline. (Cached implementation)
std::vector<Graphics::ShaderState> mShaderStates{};
// IMPLEMENTATION
-Program* Program::New(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& gfxController, Graphics::Program& gfxProgram, bool modifiesGeometry)
+Program* Program::New(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& gfxController, Graphics::UniquePtr<Graphics::Program>&& gfxProgram, bool modifiesGeometry)
{
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 );
+ gfxController.GetProgramParameter( *gfxProgram, 1, &programId );
size_t shaderHash = programId;
if(nullptr == program)
{
// program not found so create it
- program = new Program(cache, shaderData, programId, modifiesGeometry);
+ program = new Program(cache, shaderData, gfxController, std::move(gfxProgram), modifiesGeometry);
program->Load();
cache.AddProgram(shaderHash, program);
}
return mModifiesGeometry;
}
-Program::Program(ProgramCache& cache, Internal::ShaderDataPtr shaderData, uint32_t programId, bool modifiesGeometry)
+Program::Program(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& controller, Graphics::UniquePtr<Graphics::Program>&& gfxProgram, bool modifiesGeometry)
: mCache(cache),
mGlAbstraction(mCache.GetGlAbstraction()),
mProjectionMatrix(nullptr),
mVertexShaderId(0),
mFragmentShaderId(0),
mProgramId(0),
+ mGfxProgram( std::move(gfxProgram)),
+ mGfxController( controller ),
mProgramData(shaderData),
mModifiesGeometry(modifiesGeometry)
{
// reset values
ResetAttribsUniformCache();
- mProgramId = programId;
+ // Get program id and use it as hash for the cache
+ // in order to maintain current functionality as long as needed
+ mGfxController.GetProgramParameter( *mGfxProgram, 1, &mProgramId );
mLinked = true;
}
* @param[in] modifiesGeometry True if the shader modifies geometry
* @return pointer to the program
*/
- static Program* New(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& gfxController, Graphics::Program& gfxProgram, bool modifiesGeometry);
+ static Program* New(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& gfxController, Graphics::UniquePtr<Graphics::Program>&& gfxProgram, bool modifiesGeometry);
/**
* Takes this program into use
return mProgramId;
}
+ [[nodiscard]] Graphics::Program& GetGraphicsProgram() const
+ {
+ return *mGfxProgram;
+ }
+
private: // Implementation
/**
* 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] gfxProgram Graphics Program object
+ * @param[in] gfxController Reference to Graphics Controller object
* @param[in] modifiesGeometry True if the vertex shader changes geometry
*/
- Program(ProgramCache& cache, Internal::ShaderDataPtr shaderData, uint32_t programId, bool modifiesGeometry);
+ Program(ProgramCache& cache, Internal::ShaderDataPtr shaderData, Graphics::Controller& gfxController, Graphics::UniquePtr<Graphics::Program>&& gfxProgram, bool modifiesGeometry);
public:
/**
GLuint mVertexShaderId; ///< GL identifier for vertex shader
GLuint mFragmentShaderId; ///< GL identifier for fragment shader
GLuint mProgramId; ///< GL identifier for program
+ Graphics::UniquePtr<Graphics::Program> mGfxProgram; ///< Gfx program
+ Graphics::Controller& mGfxController; /// < Gfx controller
Internal::ShaderDataPtr mProgramData; ///< Shader program source and binary (when compiled & linked or loaded)
// location caches