Prechádzať zdrojové kódy

vulkan: Fix some issues with buffers and copy-to-texture

rdb 5 rokov pred
rodič
commit
1595c64ab7

+ 2 - 0
panda/src/vulkandisplay/config_vulkandisplay.cxx

@@ -12,6 +12,7 @@
  */
 
 #include "config_vulkandisplay.h"
+#include "vulkanGraphicsBuffer.h"
 #include "vulkanGraphicsPipe.h"
 #include "vulkanGraphicsStateGuardian.h"
 #include "vulkanGraphicsWindow.h"
@@ -73,6 +74,7 @@ init_libvulkandisplay() {
   }
   initialized = true;
 
+  VulkanGraphicsBuffer::init_type();
   VulkanGraphicsPipe::init_type();
   VulkanGraphicsStateGuardian::init_type();
   VulkanGraphicsWindow::init_type();

+ 2 - 1
panda/src/vulkandisplay/vulkanGraphicsBuffer.h

@@ -17,6 +17,8 @@
 #include "config_vulkandisplay.h"
 #include "graphicsBuffer.h"
 
+class VulkanTextureContext;
+
 /**
  * An offscreen buffer using the Vulkan API.
  */
@@ -64,7 +66,6 @@ private:
   };
   typedef pvector<Attachment> Attachments;
   Attachments _attachments;
-  bool _layout_defined;
 
 public:
   static TypeHandle get_class_type() {

+ 8 - 2
panda/src/vulkandisplay/vulkanGraphicsStateGuardian.cxx

@@ -2472,8 +2472,14 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z,
   nassertr(_render_pass == VK_NULL_HANDLE, false);
   nassertr(!_closing_gsg, false);
 
-  nassertr(_fb_color_tc != nullptr, false);
-  VulkanTextureContext *fbtc = _fb_color_tc;
+  VulkanTextureContext *fbtc;
+  if (rb._buffer_type & (RenderBuffer::T_depth | RenderBuffer::T_stencil)) {
+    fbtc = _fb_depth_tc;
+    nassertr(_fb_depth_tc != nullptr, false);
+  } else {
+    fbtc = _fb_color_tc;
+    nassertr(_fb_color_tc != nullptr, false);
+  }
 
   int xo, yo, w, h;
   dr->get_region_pixels(xo, yo, w, h);