GPU: Add enable_depth_clip to RasterizerState (#10964)

This commit is contained in:
Caleb Cornett
2024-09-27 11:18:54 -05:00
committed by GitHub
parent 04bb105d09
commit 5ff6e8d522
5 changed files with 22 additions and 4 deletions

View File

@@ -1356,7 +1356,7 @@ static ID3D11RasterizerState *D3D11_INTERNAL_FetchRasterizerState(
rasterizerDesc.CullMode = SDLToD3D11_CullMode[rasterizerState.cull_mode];
rasterizerDesc.DepthBias = SDL_lroundf(rasterizerState.depth_bias_constant_factor);
rasterizerDesc.DepthBiasClamp = rasterizerState.depth_bias_clamp;
rasterizerDesc.DepthClipEnable = TRUE;
rasterizerDesc.DepthClipEnable = rasterizerState.enable_depth_clip;
rasterizerDesc.FillMode = (rasterizerState.fill_mode == SDL_GPU_FILLMODE_FILL) ? D3D11_FILL_SOLID : D3D11_FILL_WIREFRAME;
rasterizerDesc.FrontCounterClockwise = (rasterizerState.front_face == SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE);
rasterizerDesc.MultisampleEnable = TRUE; // only applies to MSAA render targets

View File

@@ -2447,7 +2447,7 @@ static bool D3D12_INTERNAL_ConvertRasterizerState(SDL_GPURasterizerState rasteri
desc->SlopeScaledDepthBias = 0.0f;
}
desc->DepthClipEnable = TRUE;
desc->DepthClipEnable = rasterizerState.enable_depth_clip;
desc->MultisampleEnable = FALSE;
desc->AntialiasedLineEnable = FALSE;
desc->ForcedSampleCount = 0;

View File

@@ -368,6 +368,16 @@ static MTLColorWriteMask SDLToMetal_ColorWriteMask(
return result;
}
static MTLDepthClipMode SDLToMetal_DepthClipMode(
bool enableDepthClip
) {
if (enableDepthClip) {
return MTLDepthClipModeClip;
} else {
return MTLDepthClipModeClamp;
}
}
// Structs
typedef struct MetalTexture
@@ -2311,6 +2321,7 @@ static void METAL_BindGraphicsPipeline(
[metalCommandBuffer->renderEncoder setTriangleFillMode:SDLToMetal_PolygonMode[metalGraphicsPipeline->rasterizerState.fill_mode]];
[metalCommandBuffer->renderEncoder setCullMode:SDLToMetal_CullMode[metalGraphicsPipeline->rasterizerState.cull_mode]];
[metalCommandBuffer->renderEncoder setFrontFacingWinding:SDLToMetal_FrontFace[metalGraphicsPipeline->rasterizerState.front_face]];
[metalCommandBuffer->renderEncoder setDepthClipMode:SDLToMetal_DepthClipMode(metalGraphicsPipeline->rasterizerState.enable_depth_clip)];
[metalCommandBuffer->renderEncoder
setDepthBias:((rast->enable_depth_bias) ? rast->depth_bias_constant_factor : 0)
slopeScale:((rast->enable_depth_bias) ? rast->depth_bias_slope_factor : 0)

View File

@@ -6175,7 +6175,7 @@ static SDL_GPUGraphicsPipeline *VULKAN_CreateGraphicsPipeline(
rasterizationStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
rasterizationStateCreateInfo.pNext = NULL;
rasterizationStateCreateInfo.flags = 0;
rasterizationStateCreateInfo.depthClampEnable = VK_FALSE;
rasterizationStateCreateInfo.depthClampEnable = !createinfo->rasterizer_state.enable_depth_clip;
rasterizationStateCreateInfo.rasterizerDiscardEnable = VK_FALSE;
rasterizationStateCreateInfo.polygonMode = SDLToVK_PolygonMode(
renderer,
@@ -11030,6 +11030,8 @@ static Uint8 VULKAN_INTERNAL_CreateLogicalDevice(
desiredDeviceFeatures.independentBlend = VK_TRUE;
desiredDeviceFeatures.samplerAnisotropy = VK_TRUE;
desiredDeviceFeatures.imageCubeArray = VK_TRUE;
desiredDeviceFeatures.depthClamp = VK_TRUE;
desiredDeviceFeatures.shaderClipDistance = VK_TRUE;
if (haveDeviceFeatures.fillModeNonSolid) {
desiredDeviceFeatures.fillModeNonSolid = VK_TRUE;