Browse Source

gpu: Metal depth write should behave like Vulkan/D3D12

Ethan Lee 3 months ago
parent
commit
6cdde10edb
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/gpu/metal/SDL_gpu_metal.m

+ 2 - 1
src/gpu/metal/SDL_gpu_metal.m

@@ -1135,7 +1135,8 @@ static SDL_GPUGraphicsPipeline *METAL_CreateGraphicsPipeline(
 
             depthStencilDescriptor = [MTLDepthStencilDescriptor new];
             depthStencilDescriptor.depthCompareFunction = createinfo->depth_stencil_state.enable_depth_test ? SDLToMetal_CompareOp[createinfo->depth_stencil_state.compare_op] : MTLCompareFunctionAlways;
-            depthStencilDescriptor.depthWriteEnabled = createinfo->depth_stencil_state.enable_depth_write;
+            // Disable write when test is disabled, to match other APIs' behavior
+            depthStencilDescriptor.depthWriteEnabled = createinfo->depth_stencil_state.enable_depth_write && createinfo->depth_stencil_state.enable_depth_test;
             depthStencilDescriptor.frontFaceStencil = frontStencilDescriptor;
             depthStencilDescriptor.backFaceStencil = backStencilDescriptor;