Skip to content

Commit ae1ab0b

Browse files
committed
Fix base instance index for uniform buffer access.
1 parent de47b60 commit ae1ab0b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/apps/ch11_ssao/ch11_ssao/FrameGraph.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ std::string to_string(TextureStore::Name aName)
111111
void drawPass(const renderer::IntrospectProgram & aProgram,
112112
const scenic::SceneTree & aSceneTree)
113113
{
114+
// We populated the per-instance buffer in the order of the objects map interation
115+
// We keep track of the base-instance to access the correct index in the shader
116+
GLuint baseInstance = 0;
117+
const GLuint instanceCount = 1;
114118
glUseProgram(aProgram);
115119
for (const auto & [nodeIdx, object] : aSceneTree.mObjectsMap)
116120
{
@@ -126,14 +130,14 @@ void drawPass(const renderer::IntrospectProgram & aProgram,
126130
part.mIndicesCount,
127131
part.mIndicesType,
128132
(void *)part.mIndexFirst,
129-
1, // One instance
130-
0 /* base instance */);
133+
instanceCount, // One instance
134+
baseInstance);
131135
}
132136
else
133137
{
134138
throw std::logic_error{ "Who is not using indexed rendering?" };
135139
}
136-
140+
baseInstance += instanceCount;
137141
}
138142
}
139143
}

0 commit comments

Comments
 (0)