mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 14:18:31 +09:00
[Feat] (MG_State/Program): GetActiveAttrib
This commit is contained in:
@@ -163,7 +163,29 @@ namespace MobileGL {
|
|||||||
|
|
||||||
void GetActiveAttrib_State(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size,
|
void GetActiveAttrib_State(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size,
|
||||||
GLenum* type, GLchar* name) {
|
GLenum* type, GLchar* name) {
|
||||||
THROW_UNIMPL_EXCEPTION;
|
if (bufSize < 0) {
|
||||||
|
MG_State::pGLContext->RecordError(
|
||||||
|
ErrorCode::InvalidValue,
|
||||||
|
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||||
|
"`bufSize` is less than 0."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto programObject = TryToGetProgramObject(program);
|
||||||
|
if (!programObject)
|
||||||
|
return;
|
||||||
|
auto attribCount = programObject->GetActiveAttributesCount();
|
||||||
|
if (index >= attribCount) {
|
||||||
|
MG_State::pGLContext->RecordError(
|
||||||
|
ErrorCode::InvalidValue,
|
||||||
|
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||||
|
"`index` is greater than or equal to the number of active attribute variables in `program`."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (type != nullptr)
|
||||||
|
*type = programObject->GetAttribType(index);
|
||||||
|
if (bufSize == 0) return;
|
||||||
|
auto& attribName = programObject->GetAttribName(index);
|
||||||
|
CopyStr(bufSize, length, name, attribName.c_str(), attribName.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetActiveUniform_State(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size,
|
void GetActiveUniform_State(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size,
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ namespace MobileGL {
|
|||||||
// attributes (pipe in)
|
// attributes (pipe in)
|
||||||
int inCount = m_program->getNumPipeInputs();
|
int inCount = m_program->getNumPipeInputs();
|
||||||
m_attribs.resize(inCount);
|
m_attribs.resize(inCount);
|
||||||
|
m_attribTypes.resize(inCount);
|
||||||
|
|
||||||
// Get locations parsed in program
|
// Get locations parsed in program
|
||||||
for (int i = 0; i < inCount; i++) {
|
for (int i = 0; i < inCount; i++) {
|
||||||
@@ -100,6 +101,7 @@ namespace MobileGL {
|
|||||||
auto location = inVar.layoutLocation();
|
auto location = inVar.layoutLocation();
|
||||||
m_attribInNameMaxLength = std::max(m_attribInNameMaxLength, (Int)inVar.name.length());
|
m_attribInNameMaxLength = std::max(m_attribInNameMaxLength, (Int)inVar.name.length());
|
||||||
m_attribs[location] = inVar.name;
|
m_attribs[location] = inVar.name;
|
||||||
|
m_attribTypes[location] = inVar.glDefineType;
|
||||||
}
|
}
|
||||||
// Implement glBindAttribLocation semantics
|
// Implement glBindAttribLocation semantics
|
||||||
for (auto& [name, location]: m_explicitAttribLocations) {
|
for (auto& [name, location]: m_explicitAttribLocations) {
|
||||||
@@ -109,6 +111,7 @@ namespace MobileGL {
|
|||||||
if (it == m_attribs.end())
|
if (it == m_attribs.end())
|
||||||
continue;
|
continue;
|
||||||
std::swap(m_attribs[location], m_attribs[std::distance(m_attribs.begin(), it)]);
|
std::swap(m_attribs[location], m_attribs[std::distance(m_attribs.begin(), it)]);
|
||||||
|
std::swap(m_attribTypes[location], m_attribTypes[std::distance(m_attribs.begin(), it)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,6 +174,9 @@ namespace MobileGL {
|
|||||||
printf("decompiled src: \n%s", src.c_str());
|
printf("decompiled src: \n%s", src.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProgramObject::WaitUntilGenerationCompleted() {
|
||||||
|
}
|
||||||
|
|
||||||
void ProgramObject::SetExplicitAttribLocation(Uint index, const char *name) {
|
void ProgramObject::SetExplicitAttribLocation(Uint index, const char *name) {
|
||||||
m_explicitAttribLocations[name] = index;
|
m_explicitAttribLocations[name] = index;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,12 @@ namespace MobileGL {
|
|||||||
const auto it = std::find(m_attribs.begin(), m_attribs.end(), name);
|
const auto it = std::find(m_attribs.begin(), m_attribs.end(), name);
|
||||||
return (it == m_attribs.end()) ? -1 : std::distance(m_attribs.begin(), it);
|
return (it == m_attribs.end()) ? -1 : std::distance(m_attribs.begin(), it);
|
||||||
}
|
}
|
||||||
|
GLenum GetAttribType(Uint index) const {
|
||||||
|
return m_attribTypes[index];
|
||||||
|
}
|
||||||
|
const String& GetAttribName(Uint index) const {
|
||||||
|
return m_attribs[index];
|
||||||
|
}
|
||||||
|
|
||||||
Bool GetDeleteStatus() const { return m_deleteStatus; }
|
Bool GetDeleteStatus() const { return m_deleteStatus; }
|
||||||
Bool GetLinkStatus() const { return m_linkStatus; }
|
Bool GetLinkStatus() const { return m_linkStatus; }
|
||||||
@@ -49,6 +55,7 @@ namespace MobileGL {
|
|||||||
private:
|
private:
|
||||||
void DoReflection();
|
void DoReflection();
|
||||||
void GenerateBinary();
|
void GenerateBinary();
|
||||||
|
void WaitUntilGenerationCompleted();
|
||||||
// void PreLink();
|
// void PreLink();
|
||||||
// void PostLink();
|
// void PostLink();
|
||||||
|
|
||||||
@@ -62,6 +69,7 @@ namespace MobileGL {
|
|||||||
// Attributes
|
// Attributes
|
||||||
UnorderedMap<String, Uint> m_explicitAttribLocations;
|
UnorderedMap<String, Uint> m_explicitAttribLocations;
|
||||||
Vector<String> m_attribs;
|
Vector<String> m_attribs;
|
||||||
|
Vector<GLenum> m_attribTypes;
|
||||||
|
|
||||||
// Uniforms
|
// Uniforms
|
||||||
// MG_Util::ShaderTranspiler::SpvcMetadata m_metadata;
|
// MG_Util::ShaderTranspiler::SpvcMetadata m_metadata;
|
||||||
|
|||||||
Reference in New Issue
Block a user