mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-08 04:08:32 +09:00
[Fix] (MG_Test/Program): fix hardcoded stage-index relationship
This commit is contained in:
@@ -112,6 +112,12 @@ namespace MobileGL {
|
||||
|
||||
Vector<Vector<unsigned>>& GetGeneratedSpirv() { return m_generatedSpirv; }
|
||||
|
||||
Int GetShaderIndexByStage(ShaderStage stage) const {
|
||||
auto it = std::find_if(m_shaders.begin(), m_shaders.end(),
|
||||
[stage](const SharedPtr<ShaderObject>& shader) { return shader->GetShaderStage() == stage; });
|
||||
return it == m_shaders.end() ? -1 : std::distance(m_shaders.begin(), it);
|
||||
}
|
||||
|
||||
Uint GetExternalIndex() const { return m_externalIndex; }
|
||||
|
||||
// const UnorderedMap<String, Uint>& GetAttribLocationMap() const { return
|
||||
|
||||
@@ -983,7 +983,7 @@ TEST_F(ProgramTest, CompileAndLinkWithExplicitFragmentOut) {
|
||||
|
||||
auto programObject = MG_State::pGLContext->GetCurrentProgram();
|
||||
auto& spirvs = programObject->GetGeneratedSpirv();
|
||||
auto& fragSpirv = spirvs[0]; // 0 - fragment, 1 - vertex
|
||||
auto& fragSpirv = spirvs[programObject->GetShaderIndexByStage(ShaderStage::Fragment)];
|
||||
char* pSrcfragOut = nullptr;
|
||||
const char* needle = "layout(location = 7) out vec4 fragColor;";
|
||||
// for (auto spirv: spirvs) {
|
||||
|
||||
Reference in New Issue
Block a user