From a694caeee0c32273998190dc7c238c5fc9b8efab Mon Sep 17 00:00:00 2001
From: Subv <subv2112@gmail.com>
Date: Sun, 19 Jul 2015 14:09:23 -0500
Subject: [PATCH] GLRasterizer: Don't try to get a pointer to the depth buffer
 if it doesn't exist.

---
 src/video_core/renderer_opengl/gl_rasterizer.cpp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 935a9f281..2db845da6 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -816,12 +816,16 @@ void RasterizerOpenGL::ReloadColorBuffer() {
 }
 
 void RasterizerOpenGL::ReloadDepthBuffer() {
-    // TODO: Appears to work, but double-check endianness of depth values and order of depth-stencil
-    u8* depth_buffer = Memory::GetPhysicalPointer(Pica::g_state.regs.framebuffer.GetDepthBufferPhysicalAddress());
+    PAddr depth_buffer_addr = Pica::g_state.regs.framebuffer.GetDepthBufferPhysicalAddress();
 
-    if (depth_buffer == nullptr) {
+    if (depth_buffer_addr == 0)
+        return;
+
+    // TODO: Appears to work, but double-check endianness of depth values and order of depth-stencil
+    u8* depth_buffer = Memory::GetPhysicalPointer(depth_buffer_addr);
+
+    if (depth_buffer == nullptr)
         return;
-    }
 
     u32 bytes_per_pixel = Pica::Regs::BytesPerDepthPixel(fb_depth_texture.format);