Procházet zdrojové kódy

vulkan: Support DepthBiasAttrib

rdb před 4 dny
rodič
revize
328fa54a5f

+ 12 - 4
panda/src/vulkandisplay/vulkanGraphicsStateGuardian.cxx

@@ -5268,10 +5268,18 @@ make_pipeline(VulkanShaderContext *sc,
 
   raster_info.cullMode = (VkCullModeFlagBits)key._cull_face_mode;
   raster_info.frontFace = VK_FRONT_FACE_CLOCKWISE; // Flipped
-  raster_info.depthBiasEnable = VK_FALSE;
-  raster_info.depthBiasConstantFactor = 0;
-  raster_info.depthBiasClamp = 0;
-  raster_info.depthBiasSlopeFactor = 0;
+
+  if (key._depth_bias_attrib != nullptr) {
+    raster_info.depthBiasEnable = VK_TRUE;
+    raster_info.depthBiasConstantFactor = key._depth_bias_attrib->get_constant_factor();
+    raster_info.depthBiasClamp = key._depth_bias_attrib->get_clamp();
+    raster_info.depthBiasSlopeFactor = key._depth_bias_attrib->get_slope_factor();
+  } else {
+    raster_info.depthBiasEnable = VK_FALSE;
+    raster_info.depthBiasConstantFactor = 0;
+    raster_info.depthBiasClamp = 0;
+    raster_info.depthBiasSlopeFactor = 0;
+  }
 
   VkPipelineMultisampleStateCreateInfo ms_info;
   ms_info.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;

+ 5 - 1
panda/src/vulkandisplay/vulkanShaderContext.I

@@ -59,7 +59,8 @@ operator ==(const PipelineKey &other) const {
       && _logic_op == other._logic_op
       && _color_blend_attrib == other._color_blend_attrib
       && _transparency_mode == other._transparency_mode
-      && _alpha_test_attrib == other._alpha_test_attrib;
+      && _alpha_test_attrib == other._alpha_test_attrib
+      && _depth_bias_attrib == other._depth_bias_attrib;
 }
 
 /**
@@ -109,5 +110,8 @@ operator < (const PipelineKey &other) const {
   if (_alpha_test_attrib != other._alpha_test_attrib) {
     return _alpha_test_attrib < other._alpha_test_attrib;
   }
+  if (_depth_bias_attrib != other._depth_bias_attrib) {
+    return _depth_bias_attrib < other._depth_bias_attrib;
+  }
   return 0;
 }

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

@@ -1010,6 +1010,8 @@ get_pipeline(VulkanGraphicsStateGuardian *gsg, const RenderState *state,
     key._alpha_test_attrib = alpha_test;
   }
 
+  state->get_attrib(key._depth_bias_attrib);
+
   PipelineMap::const_iterator it;
   it = _pipeline_map.find(key);
   if (it == _pipeline_map.end()) {

+ 2 - 0
panda/src/vulkandisplay/vulkanShaderContext.h

@@ -26,6 +26,7 @@
 #include "colorBlendAttrib.h"
 #include "alphaTestAttrib.h"
 #include "transparencyAttrib.h"
+#include "depthBiasAttrib.h"
 
 #include "small_vector.h"
 
@@ -101,6 +102,7 @@ public:
     CPT(ColorBlendAttrib) _color_blend_attrib;
     TransparencyAttrib::Mode _transparency_mode;
     CPT(AlphaTestAttrib) _alpha_test_attrib;
+    CPT(DepthBiasAttrib) _depth_bias_attrib;
   };
 
 private: