Skip to content

Commit 54cfc95

Browse files
committed
Fix accidentally creating an additional output swap chain when it isn't needed
1 parent 4be40ca commit 54cfc95

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/oculus/oculus_manager.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ namespace vrperfkit {
170170

171171
for (int eye = 0; eye < 2; ++eye) {
172172
d3d11Res->multisampled[eye] = false;
173-
if (submittedEyeChains[eye] == nullptr)
173+
if (submittedEyeChains[eye] == nullptr || (eye == 1 && submittedEyeChains[1] == submittedEyeChains[0]))
174174
continue;
175175

176176
int length = 0;
@@ -232,7 +232,8 @@ namespace vrperfkit {
232232

233233
d3d11Res->usingArrayTex = false;
234234

235-
if (submittedEyeChains[1] == nullptr) {
235+
if (outputEyeChains[1] == nullptr) {
236+
outputEyeChains[1] = outputEyeChains[0];
236237
LOG_INFO << "Game is using a single texture for both eyes";
237238
d3d11Res->submittedTextures[1] = d3d11Res->submittedTextures[0];
238239
d3d11Res->resolveTexture[1] = d3d11Res->resolveTexture[0];
@@ -273,6 +274,7 @@ namespace vrperfkit {
273274

274275
void OculusManager::PostProcessD3D11(ovrLayerEyeFovDepth &eyeLayer) {
275276
auto projCenters = CalculateProjectionCenter(eyeLayer.Fov);
277+
bool successfulPostprocessing = false;
276278

277279
for (int eye = 0; eye < 2; ++eye) {
278280
int index;
@@ -321,17 +323,24 @@ namespace vrperfkit {
321323

322324
Viewport outputViewport;
323325
if (d3d11Res->postProcessor->Apply(input, outputViewport)) {
324-
ovr_CommitTextureSwapChain(session, outputEyeChains[eye]);
325326
eyeLayer.ColorTexture[eye] = outputEyeChains[eye];
326327
eyeLayer.Viewport[eye].Pos.x = outputViewport.x;
327328
eyeLayer.Viewport[eye].Pos.y = outputViewport.y;
328329
eyeLayer.Viewport[eye].Size.w = outputViewport.width;
329330
eyeLayer.Viewport[eye].Size.h = outputViewport.height;
331+
successfulPostprocessing = true;
330332
}
331333

332334
D3D11_TEXTURE2D_DESC td;
333335
input.inputTexture->GetDesc(&td);
334336
d3d11Res->variableRateShading->UpdateTargetInformation(td.Width, td.Height, input.mode, projCenters.eyeCenter[0].x, projCenters.eyeCenter[0].y, projCenters.eyeCenter[1].x, projCenters.eyeCenter[1].y);
335337
}
338+
339+
if (successfulPostprocessing) {
340+
ovr_CommitTextureSwapChain(session, outputEyeChains[0]);
341+
if (outputEyeChains[1] != outputEyeChains[0]) {
342+
ovr_CommitTextureSwapChain(session, outputEyeChains[1]);
343+
}
344+
}
336345
}
337346
}

0 commit comments

Comments
 (0)