feat(vkbridge): VK_EXT_depth_clip_enable emulation via depth clamp; D3D11 DepthClipEnable check

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KZqR8XUE8czvGzEpgSCVQR
This commit is contained in:
ahmadandClaude Opus 5.5 authored and Ahmad Sayed Alsayed Ebrahim committed 2026-10-10 14:28:13 +03:00
1 parent 02a06bec3f
commit c4ac049007
6 files changed
+75 -4

No files matched your search

+8
View File
@@ -71,6 +71,14 @@ void vkb_emu_patch_features_chain(vkb_physdev *pd, VkBaseOutStructure *b)
set_feature(pd, VKB_EMU_DIVISOR, &d->vertexAttributeInstanceRateZeroDivisor);
break;
}
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_3_FEATURES_EXT:
/* Emulated depth clip is pipeline state (clamp = not clip): neither may be dynamic. */
if (MISSING(pd, VKB_EMU_DEPTH_CLIP) || EMU(pd, VKB_EMU_DEPTH_CLIP)) {
VkPhysicalDeviceExtendedDynamicState3FeaturesEXT *d3 = (void *)b;
d3->extendedDynamicState3DepthClipEnable = VK_FALSE;
if (EMU(pd, VKB_EMU_DEPTH_CLIP)) d3->extendedDynamicState3DepthClampEnable = VK_FALSE;
}
break;
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT:
set_feature(pd, VKB_EMU_DEPTH_CLIP, &((VkPhysicalDeviceDepthClipEnableFeaturesEXT *)b)->depthClipEnable);
break;
+2 -2
View File
@@ -5,11 +5,11 @@ _vkb_host=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
export VKBRIDGE_SOCKET=${XDG_RUNTIME_DIR:-/tmp}/vkbridge-host.sock
pgrep -x vkbridge-server >/dev/null && kill $(pgrep -x vkbridge-server) 2>/dev/null; sleep 0.3
rm -f "$VKBRIDGE_SOCKET"
VKBRIDGE_FAKE_MISSING=${VKB_MISSING:-bc,clip,cull,divisor,maint5} VK_DRIVER_FILES=${VKB_HOST_ICD:-/usr/share/vulkan/icd.d/radeon_icd.json} \
VKBRIDGE_FAKE_MISSING=${VKB_MISSING:-bc,clip,cull,divisor,maint5,depthclip} VK_DRIVER_FILES=${VKB_HOST_ICD:-/usr/share/vulkan/icd.d/radeon_icd.json} \
nohup "$_vkb_host/out/vkbridge-server" --socket "$VKBRIDGE_SOCKET" --log "$_vkb_host/out/server.log" >/dev/null 2>&1 &
for _i in $(seq 50); do [ -S "$VKBRIDGE_SOCKET" ] && break; sleep 0.1; done
chmod 666 "$VKBRIDGE_SOCKET"
export VK_DRIVER_FILES=$_vkb_host/out/vkbridge_icd.json
export VKBRIDGE_HIDE_EXTS=VK_KHR_maintenance5,VK_EXT_vertex_attribute_divisor,VK_KHR_vertex_attribute_divisor
export VKBRIDGE_HIDE_EXTS=VK_KHR_maintenance5,VK_EXT_vertex_attribute_divisor,VK_KHR_vertex_attribute_divisor,VK_EXT_depth_clip_enable
export VKBRIDGE_MAX_API=1.3
echo "vkbridge server up, imitating Mali's gaps"
+37
View File
@@ -302,6 +302,42 @@ static void test_step_rate(void)
check(ok, "instance step rate 2", d);
}
/* ------------------------------------------------------------------ depth clip */
static void test_depth_clip(void)
{
/* A full-screen triangle at z = 1.5 (beyond the far plane): clipped away with depth clip on,
* visible (clamped to the far plane) with it off. */
const char *vs = "float4 main(uint id : SV_VertexID) : SV_Position { float2 t = float2((id << 1) & 2, id & 2);"
"return float4(t * float2(2, -2) + float2(-1, 1), 1.5, 1); }";
const char *ps = "float4 main() : SV_Target { return float4(1, 1, 1, 1); }";
ID3DBlob *v = compile(vs, "main", "vs_5_0"), *p = compile(ps, "main", "ps_5_0");
ID3D11VertexShader *vsh;
ID3D11PixelShader *psh;
ID3D11Device_CreateVertexShader(dev, ID3D10Blob_GetBufferPointer(v), ID3D10Blob_GetBufferSize(v), NULL, &vsh);
ID3D11Device_CreatePixelShader(dev, ID3D10Blob_GetBufferPointer(p), ID3D10Blob_GetBufferSize(p), NULL, &psh);
uint32_t got[2];
for (int on = 1; on >= 0; on--) {
D3D11_RASTERIZER_DESC rd = {D3D11_FILL_SOLID, D3D11_CULL_NONE, FALSE, 0, 0, 0, on ? TRUE : FALSE, FALSE, FALSE, FALSE};
ID3D11RasterizerState *rs;
ID3D11Device_CreateRasterizerState(dev, &rd, &rs);
ID3D11DeviceContext_RSSetState(ctx, rs);
bind_target();
clear(0, 0, 0);
ID3D11DeviceContext_IASetInputLayout(ctx, NULL);
ID3D11DeviceContext_IASetPrimitiveTopology(ctx, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
ID3D11DeviceContext_VSSetShader(ctx, vsh, NULL, 0);
ID3D11DeviceContext_PSSetShader(ctx, psh, NULL, 0);
ID3D11DeviceContext_Draw(ctx, 3, 0);
const uint32_t *px = readback();
got[on] = px ? px[TH / 2 * TW + TW / 2] : 0;
}
ID3D11DeviceContext_RSSetState(ctx, NULL);
char d[96];
snprintf(d, sizeof d, "clip on 0x%08x (want black), off 0x%08x (want white)", got[1], got[0]);
check(close_to(got[1], 0xFF000000, 2) && close_to(got[0], 0xFFFFFFFF, 2), "DepthClipEnable", d);
}
int main(void)
{
D3D_FEATURE_LEVEL fl = D3D_FEATURE_LEVEL_11_0, got;
@@ -324,6 +360,7 @@ int main(void)
tests_bc();
test_clip();
test_step_rate();
test_depth_clip();
printf("%s: %d of %d checks passed\n", failures ? "FAILED" : "OK", checks - failures, checks);
return failures ? 1 : 0;
}