diff --git a/code/graphics/vulkan/VulkanDraw.cpp b/code/graphics/vulkan/VulkanDraw.cpp index e33f25105a..b828dcc807 100644 --- a/code/graphics/vulkan/VulkanDraw.cpp +++ b/code/graphics/vulkan/VulkanDraw.cpp @@ -1283,6 +1283,7 @@ bool VulkanDrawManager::applyMaterial(material* mat, primitive_type prim_type, v // Like opengl_tnl_set_material(), every material draw sets the texture addressing (e.g. MR_FORCE_CLAMP skyboxes) setTextureAddressing(mat->get_texture_addressing()); + vulkan_zbias(mat->get_depth_bias()); // Build pipeline configuration from material PipelineConfig config = buildPipelineConfig(mat, prim_type); @@ -1483,9 +1484,6 @@ bool VulkanDrawManager::applyMaterial(material* mat, primitive_type prim_type, v stateTracker->setStencilMode(GR_STENCIL_NONE); } - // Set depth bias if needed - stateTracker->setDepthBias(static_cast(mat->get_depth_bias()), 0.0f); - return true; } @@ -1543,7 +1541,7 @@ void VulkanDrawManager::draw(primitive_type prim_type, int first_vertex, int ver m_frameStats.totalVertices += vertex_count; // Flush any dirty dynamic state (viewport, scissor, depth bias, stencil ref) - // before issuing the draw command. applyMaterial sets these AFTER bindPipeline, + // before issuing the draw command. applyMaterial sets some of these AFTER bindPipeline, // so they may be dirty even when the pipeline didn't change. stateTracker->applyDynamicState(); diff --git a/code/graphics/vulkan/VulkanState.cpp b/code/graphics/vulkan/VulkanState.cpp index a7acb744c1..f609c1b2f6 100644 --- a/code/graphics/vulkan/VulkanState.cpp +++ b/code/graphics/vulkan/VulkanState.cpp @@ -351,9 +351,9 @@ void vulkan_zbias(int bias) if (bias) { drawManager->setDepthBiasEnabled(true); if (bias < 0) { - stateTracker->setDepthBias(1.0f, static_cast(-bias)); + stateTracker->setDepthBias(static_cast(-bias), 1.0f); } else { - stateTracker->setDepthBias(0.0f, static_cast(-bias)); + stateTracker->setDepthBias(static_cast(-bias), 0.0f); } } else { drawManager->setDepthBiasEnabled(false); diff --git a/code/graphics/vulkan/VulkanState.h b/code/graphics/vulkan/VulkanState.h index f4da4d3b1a..d8576df5cc 100644 --- a/code/graphics/vulkan/VulkanState.h +++ b/code/graphics/vulkan/VulkanState.h @@ -293,7 +293,7 @@ class VulkanStateTracker { * * Must be called before every draw command to ensure dirty dynamic state * (viewport, scissor, depth bias, stencil ref, line width) is flushed. - * applyMaterial() sets depth bias/stencil AFTER bindPipeline(), so if + * applyMaterial() sets the stencil reference AFTER bindPipeline(), so if * the pipeline didn't change, those changes would be lost without this. */ void applyDynamicState();