mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-09 12:48:32 +09:00
[Feat]: Implement glBindFragDataLocation and glGetFragDataLocation
This commit is contained in:
@@ -86,7 +86,8 @@ namespace MobileGL {
|
||||
|
||||
MG_Util::ShaderTranspiler::ProgramAttrib attrib{
|
||||
.shaders = Move(shaders),
|
||||
.explicitVertexInLocations = m_explicitAttribLocations
|
||||
.explicitVertexInLocations = m_explicitAttribLocations,
|
||||
.explicitFragmentOutLocations = m_explicitFragDataLocation
|
||||
};
|
||||
|
||||
MGLOG_D("ProgramObject %u: Calling ShaderCompiler::LinkProgram", m_externalIndex);
|
||||
@@ -376,7 +377,8 @@ namespace MobileGL {
|
||||
|
||||
ProgramAttrib attrib{
|
||||
.shaders = Move(shaders),
|
||||
.explicitVertexInLocations = m_explicitAttribLocations
|
||||
.explicitVertexInLocations = m_explicitAttribLocations,
|
||||
.explicitFragmentOutLocations = m_explicitFragDataLocation
|
||||
};
|
||||
MGLOG_D("ProgramObject %u: GenerateBinary - linking program for binary", m_externalIndex);
|
||||
auto programResult = ShaderCompiler::LinkProgram(attrib);
|
||||
@@ -472,6 +474,22 @@ namespace MobileGL {
|
||||
MGLOG_D("ProgramObject %u: SetExplicitVertexInLocation - stored explicit location for '%s' -> %u",
|
||||
m_externalIndex, name, index);
|
||||
}
|
||||
|
||||
void ProgramObject::SetExplicitFragmentOutLocation(Uint index, const char* name) {
|
||||
MGLOG_D("ProgramObject %u: SetExplicitFragmentOutLocation called name='%s' index=%u", m_externalIndex, name,
|
||||
index);
|
||||
m_explicitFragDataLocation[name] = index;
|
||||
MGLOG_D("ProgramObject %u: SetExplicitFragmentOutLocation - stored explicit location for '%s' -> %u",
|
||||
m_externalIndex, name, index);
|
||||
}
|
||||
|
||||
Int ProgramObject::GetFragmentDataLocation(const char* name) {
|
||||
// TODO: should retrieve "post-mortem" location from glslang instead
|
||||
auto it = m_explicitFragDataLocation.find(name);
|
||||
if (it == m_explicitFragDataLocation.end())
|
||||
return -1;
|
||||
return it->second;
|
||||
}
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace MobileGL {
|
||||
void MarkAsDeleted();
|
||||
|
||||
void SetExplicitVertexInLocation(Uint index, const char* name);
|
||||
void SetExplicitFragmentOutLocation(Uint index, const char* name);
|
||||
Int GetFragmentDataLocation(const char* name);
|
||||
|
||||
Vector<SharedPtr<ShaderObject>>& GetAttachedShaders();
|
||||
const String& GetInfoLog() const { return m_infoLog; }
|
||||
@@ -119,13 +121,16 @@ namespace MobileGL {
|
||||
|
||||
Vector<Vector<unsigned>> m_generatedSpirv;
|
||||
|
||||
// Attributes
|
||||
// Attributes (Vertex in)
|
||||
UnorderedMap<String, Uint> m_explicitAttribLocations;
|
||||
Vector<String> m_attribs;
|
||||
Vector<GLenum> m_attribTypes;
|
||||
// For SpvcSession::SetVertexAttribLocation()
|
||||
// UnorderedMap<String, Uint> m_attribLocation;
|
||||
|
||||
// FragData (Frag out)
|
||||
UnorderedMap<String, Uint> m_explicitFragDataLocation;
|
||||
|
||||
// Uniforms
|
||||
UnorderedMap<String, Uint> m_uniformLocations;
|
||||
// Ordered by location,
|
||||
|
||||
Reference in New Issue
Block a user