mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-09 04:38:30 +09:00
[Feat] (MG_State/Program): GetAttachedShaders
This commit is contained in:
@@ -59,6 +59,10 @@ namespace MobileGL {
|
||||
void ProgramObject::MarkAsDeleted() {
|
||||
m_deleteStatus = true;
|
||||
}
|
||||
|
||||
Vector<SharedPtr<ShaderObject>>& ProgramObject::GetAttachedShaders() {
|
||||
return m_shaders;
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
@@ -7,12 +7,15 @@ namespace MobileGL {
|
||||
namespace GLState {
|
||||
class ProgramObject {
|
||||
public:
|
||||
ProgramObject(const Uint id): m_id(id) {}
|
||||
bool ShaderIsAttached(SharedPtr<ShaderObject> shader);
|
||||
bool AttachShader(SharedPtr<ShaderObject> shader);
|
||||
SizeT DetachShader(SharedPtr<ShaderObject> shader);
|
||||
void Link();
|
||||
void MarkAsDeleted();
|
||||
Vector<SharedPtr<ShaderObject>>& GetAttachedShaders();
|
||||
private:
|
||||
const Uint m_id = 0;
|
||||
Vector<SharedPtr<ShaderObject>> m_shaders;
|
||||
// basically this contains SPIR-V in binary format
|
||||
Vector<Vector<Uint>> m_programBinary;
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace MobileGL {
|
||||
Uint programId = 0;
|
||||
m_programIndexGenerator.Generate(1, &programId);
|
||||
EnsureIndexAvail(programId, m_programObjects);
|
||||
auto programObject = MakeShared<ProgramObject>();
|
||||
auto programObject = MakeShared<ProgramObject>(programId);
|
||||
if (programObject == nullptr)
|
||||
return 0;
|
||||
m_programObjects[programId] = programObject;
|
||||
@@ -45,7 +45,7 @@ namespace MobileGL {
|
||||
Uint shaderId = 0;
|
||||
m_shaderIndexGenerator.Generate(1, &shaderId);
|
||||
EnsureIndexAvail(shaderId, m_shaderObjects);
|
||||
auto shaderObject = MakeShared<ShaderObject>(stage);
|
||||
auto shaderObject = MakeShared<ShaderObject>(stage, shaderId);
|
||||
if (shaderObject == nullptr)
|
||||
return 0;
|
||||
m_shaderObjects[shaderId] = shaderObject;
|
||||
|
||||
@@ -56,16 +56,18 @@ namespace MobileGL {
|
||||
|
||||
class ShaderObject {
|
||||
public:
|
||||
ShaderObject(const ShaderStage stage) : m_stage(stage) {}
|
||||
ShaderObject(const ShaderStage stage, const Uint id) : m_stage(stage), m_id(id) {}
|
||||
void SetShaderSource(const std::string& source);
|
||||
void SetShaderSource(std::string&& source);
|
||||
void Compile();
|
||||
void MarkAsDeleted();
|
||||
|
||||
Uint GetId() const { return m_id; }
|
||||
ShaderStage GetShaderStage() const { return m_stage; }
|
||||
const std::string& GetShaderSource() const { return m_source; }
|
||||
SharedPtr<glslang::TShader> GetCompiledShader() const { return m_shader; }
|
||||
private:
|
||||
const Uint m_id = 0;
|
||||
const ShaderStage m_stage;
|
||||
std::string m_source;
|
||||
SharedPtr<glslang::TShader> m_shader;
|
||||
|
||||
Reference in New Issue
Block a user