From 6cdde10edb9770555b104f6058d68ade90016085 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Thu, 9 Jan 2025 15:18:54 -0500 Subject: [PATCH] gpu: Metal depth write should behave like Vulkan/D3D12 --- src/gpu/metal/SDL_gpu_metal.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gpu/metal/SDL_gpu_metal.m b/src/gpu/metal/SDL_gpu_metal.m index eaa4d848ce..415b38c5bd 100644 --- a/src/gpu/metal/SDL_gpu_metal.m +++ b/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;