@@ -40,6 +40,19 @@ void VkDeviceOverrides::DestroyImage(const vkroots::VkDeviceDispatch& pDispatch,
4040 pDispatch.DestroyImage (device, image, pAllocator);
4141}
4242
43+
44+ void CemuHooks::hook_FixCameraSaveFilesAndInventory (PPCInterpreter_t* hCPU) {
45+ hCPU->instructionPointer = hCPU->sprNew .LR ;
46+
47+ uint32_t isEnabling3DFramebufferCapture = hCPU->gpr [3 ];
48+ EyeSide side = (EyeSide)hCPU->gpr [4 ];
49+ uint32_t frameIdx = hCPU->gpr [5 ];
50+
51+ Log::print<PPC>(" hook_FixCameraSaveFilesAndInventory: isEnabling3DFramebufferCapture={}, side={}, frameIdx={}" , isEnabling3DFramebufferCapture, side, frameIdx);
52+ VRManager::instance ().XR ->GetRenderer ()->SignalGameCapturing3DFrameBuffer ();
53+ }
54+
55+
4356void VkDeviceOverrides::CmdClearColorImage (const vkroots::VkCommandBufferDispatch& pDispatch, VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges) {
4457 // check whether the magic values are there, and which order they are in to determine which eye
4558 OpenXR::EyeSide side = (OpenXR::EyeSide)-1 ;
@@ -128,6 +141,13 @@ void VkDeviceOverrides::CmdClearColorImage(const vkroots::VkCommandBufferDispatc
128141 VulkanUtils::DebugPipelineBarrier (commandBuffer);
129142 };
130143
144+ RND_Renderer::RenderFrame& frame = renderer->GetFrame (frameIdx);
145+
146+ auto clearFramebuffer = [&](bool disableAlpha) -> void {
147+ VkClearColorValue clearColor = disableAlpha ? VkClearColorValue{ { 0 .0f , 0 .0f , 0 .0f , 1 .0f } } : VkClearColorValue{ { 0 .0f , 0 .0f , 0 .0f , 0 .0f } };
148+ pDispatch.CmdClearColorImage (commandBuffer, image, imageLayout, &clearColor, rangeCount, pRanges);
149+ };
150+
131151 // 3D layer - color texture for 3D rendering
132152 if (captureIdx == 0 ) {
133153 // check if the color texture has the appropriate texture format
@@ -149,24 +169,19 @@ void VkDeviceOverrides::CmdClearColorImage(const vkroots::VkCommandBufferDispatc
149169
150170 if (image != s_curr3DColorImage) {
151171 Log::print<RENDERING>(" Color image is not the same as the current 3D color image! ({} != {})" , (void *)image, (void *)s_curr3DColorImage);
152- VkClearColorValue clearColor;
153- if (VRManager::instance ().XR ->GetRenderer ()->IsRendering3D (frameIdx)) {
154- clearColor = {{ 0 .0f , 0 .0f , 0 .0f , 0 .0f }};
155- }
156- else {
157- clearColor = {{ 0 .0f , 0 .0f , 0 .0f , 1 .0f }};
158- }
159172 returnToLayout ();
160- return pDispatch. CmdClearColorImage (commandBuffer, image, imageLayout, &clearColor, rangeCount, pRanges );
173+ return clearFramebuffer (! VRManager::instance (). XR -> GetRenderer ()-> IsRendering3D (frameIdx) );
161174 }
162175
163176 if (renderer->GetFrame (frameIdx).copiedColor [side]) {
164177 // the color texture has already been copied to the layer
165178 Log::print<RENDERING>(" A 3D color texture is already been copied for the current frame!" );
166179
167- VkClearColorValue clearColor = {{ 0 .0f , 0 .0f , 0 .0f , 0 .0f }};
168180 returnToLayout ();
169- return pDispatch.CmdClearColorImage (commandBuffer, image, imageLayout, &clearColor, rangeCount, pRanges);
181+ if (CemuHooks::UseMonoFrameBufferTemporarilyDuringMenusOrPictures ()) {
182+ return ;
183+ }
184+ return clearFramebuffer (false );
170185 }
171186
172187 // note: This uses vkCmdCopyImage to copy the image to the D3D12-created interop texture. s_activeCopyOperations queues a semaphore for the D3D12 side to wait on.
@@ -178,6 +193,10 @@ void VkDeviceOverrides::CmdClearColorImage(const vkroots::VkCommandBufferDispatc
178193 s_activeCopyOperations.emplace_back (commandBuffer, texture);
179194 }
180195
196+ if (CemuHooks::UseMonoFrameBufferTemporarilyDuringMenusOrPictures ()) {
197+ return ;
198+ }
199+
181200 // imgui needs only one eye to render Cemu's 2D output, so use right side since it looks better
182201 if (side == EyeSide::RIGHT) {
183202 // note: Uses vkCmdCopyImage to copy the (right-eye-only) image to the imgui overlay's texture
@@ -186,23 +205,21 @@ void VkDeviceOverrides::CmdClearColorImage(const vkroots::VkCommandBufferDispatc
186205 }
187206
188207 // clear the image to be transparent to allow for the HUD to be rendered on top of it which results in a transparent HUD layer
189- VkClearColorValue clearColor = {{ 0 .0f , 0 .0f , 0 .0f , 0 .0f }};
190208 returnToLayout ();
191- return pDispatch. CmdClearColorImage (commandBuffer, image, imageLayout, &clearColor, rangeCount, pRanges );
209+ return clearFramebuffer ( false );
192210 }
193211
194212 // 2D layer - color texture for HUD rendering
195213 if (captureIdx == 2 ) {
196214 bool hudCopied = renderer->GetFrame (frameIdx).copied2D ;
197215
198- if (side == OpenXR:: EyeSide::LEFT) {
216+ if (side == EyeSide::LEFT) {
199217 if (hudCopied) {
200218 // the 2D texture has already been copied to the layer
201219 Log::print<RENDERING>(" A 2D texture has already been copied for the current frame!" );
202220
203- VkClearColorValue clearColor = {{ 0 .0f , 0 .0f , 0 .0f , 0 .0f }};
204221 returnToLayout ();
205- return pDispatch. CmdClearColorImage (commandBuffer, image, imageLayout, &clearColor, rangeCount, pRanges );
222+ return clearFramebuffer ( false );
206223 }
207224 else {
208225 // provide the HUD texture to the imgui overlay we'll use to recomposite Cemu's original flatscreen rendering
@@ -232,7 +249,7 @@ void VkDeviceOverrides::CmdClearColorImage(const vkroots::VkCommandBufferDispatc
232249 return ;
233250 }
234251 }
235- if (side == OpenXR:: EyeSide::RIGHT) {
252+ if (side == EyeSide::RIGHT) {
236253 // render the imgui overlay on the right side
237254 if (imguiOverlay) {
238255 // render imgui, and then copy the framebuffer to the 2D layer
@@ -244,12 +261,12 @@ void VkDeviceOverrides::CmdClearColorImage(const vkroots::VkCommandBufferDispatc
244261 }
245262
246263 if (hudCopied) {
247- VkClearColorValue clearColor = {{ 0 .0f , 0 .0f , 0 .0f , 0 .0f }};
248264 returnToLayout ();
249- return pDispatch. CmdClearColorImage (commandBuffer, image, imageLayout, &clearColor, rangeCount, pRanges );
265+ return clearFramebuffer ( false );
250266 }
251267 }
252268 }
269+ returnToLayout ();
253270 return ;
254271 }
255272 else {
0 commit comments