mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 22:36:00 +00:00
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:
1 parent
02a06bec3f
commit
c4ac049007
6 files changed
+75
-4
No files matched your search
@@ -99,7 +99,7 @@ void vkb_emu_device_create_info(vkb_srv_table *inst, VkPhysicalDevice pd, uint32
|
||||
VkPhysicalDeviceFeatures real;
|
||||
inst->real.vkGetPhysicalDeviceFeatures(pd, &real);
|
||||
VkPhysicalDeviceFeatures *f = find_features(ci);
|
||||
if ((emu & VKB_EMU_BCN) && !f) {
|
||||
if ((emu & (VKB_EMU_BCN | VKB_EMU_DEPTH_CLIP)) && !f) {
|
||||
/* The BC decoder writes R8/RG8 storage images: it needs this feature on, so the request
|
||||
* gets a features structure if it had none. */
|
||||
f = vkb_arena_alloc(a, sizeof(*f));
|
||||
@@ -114,6 +114,7 @@ void vkb_emu_device_create_info(vkb_srv_table *inst, VkPhysicalDevice pd, uint32
|
||||
if (want[i] && !have[i]) want[i] = VK_FALSE;
|
||||
}
|
||||
if (emu & VKB_EMU_BCN) f->shaderStorageImageExtendedFormats = VK_TRUE;
|
||||
if (emu & VKB_EMU_DEPTH_CLIP) f->depthClamp = VK_TRUE;
|
||||
}
|
||||
if (emu & VKB_EMU_DIVISOR) chain_remove(ci, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT);
|
||||
if (emu & VKB_EMU_DEPTH_CLIP) chain_remove(ci, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
/* Emulations that are implemented (the rest are never offered to the client). */
|
||||
#define VKB_EMU_IMPLEMENTED (VKB_EMU_MAINT5 | VKB_EMU_CLIP_DISTANCE | VKB_EMU_CULL_DISTANCE | VKB_EMU_POINT_SIZE | VKB_EMU_BCN | \
|
||||
VKB_EMU_DIVISOR)
|
||||
VKB_EMU_DIVISOR | VKB_EMU_DEPTH_CLIP)
|
||||
|
||||
#define VKB_EMU_BUCKETS 1024
|
||||
|
||||
@@ -63,6 +63,8 @@ void vkb_emu_bcn_buffer_usage(vkb_emu_device *e, VkBufferCreateInfo *ci);
|
||||
int vkb_emu_bcn_blocks_readback(vkb_emu_device *e, VkImage img);
|
||||
|
||||
/* layer (server_emu_layer.c) */
|
||||
void vkb_emu_depth_clip_pipeline(vkb_emu_device *e, VkGraphicsPipelineCreateInfo *ci);
|
||||
void vkb_emu_depth_clip_install(vkb_srv_table *dev);
|
||||
vkb_emu_device *vkb_emu_cur(void);
|
||||
const vkb_dispatch *vkb_emu_real(void);
|
||||
void *vkb_emu_chain_take(const void *head, VkStructureType t);
|
||||
|
||||
@@ -204,6 +204,7 @@ static VKAPI_ATTR VkResult VKAPI_CALL emu_CreateGraphicsPipelines(VkDevice devic
|
||||
for (uint32_t i = 0; i < n; i++) {
|
||||
VkGraphicsPipelineCreateInfo *ci = (VkGraphicsPipelineCreateInfo *)&infos[i];
|
||||
vkb_emu_divisor_pipeline(e, device, ci, (div_info *)(divs + i * dsz));
|
||||
vkb_emu_depth_clip_pipeline(e, ci);
|
||||
/* Shader rewrites first: they read inline SPIR-V before it becomes a module. */
|
||||
vkb_emu_shader_pipeline(e, device, ci, mods, &nmods, 64);
|
||||
if (e->flags & VKB_EMU_MAINT5) {
|
||||
@@ -432,6 +433,7 @@ void vkb_emu_install(vkb_srv_table *dev)
|
||||
if (dev->real.vkCmdBindVertexBuffers2) dt->vkCmdBindVertexBuffers2 = emu_CmdBindVertexBuffers2;
|
||||
}
|
||||
vkb_emu_install_features(dev);
|
||||
vkb_emu_depth_clip_install(dev);
|
||||
VKB_INFO("device %u: emulation 0x%x installed", dev->id, e->flags);
|
||||
}
|
||||
|
||||
@@ -453,3 +455,24 @@ void vkb_emu_uninstall(vkb_srv_table *dev)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ depth clip enable */
|
||||
|
||||
/* VK_EXT_depth_clip_enable on a GPU without it. Without the extension Vulkan clips exactly when
|
||||
* depth clamp is off, so a pipeline's clamp becomes "not clip" (D3D's DepthClipEnable = FALSE is
|
||||
* clamping; clip + clamp only differs for fragments the clip removes anyway). The client hides
|
||||
* dynamic depth clip/clamp while this is emulated, so both are static pipeline state here. */
|
||||
void vkb_emu_depth_clip_pipeline(vkb_emu_device *e, VkGraphicsPipelineCreateInfo *ci)
|
||||
{
|
||||
if (!(e->flags & VKB_EMU_DEPTH_CLIP)) return;
|
||||
VkPipelineRasterizationStateCreateInfo *rs = (VkPipelineRasterizationStateCreateInfo *)ci->pRasterizationState;
|
||||
if (!rs) return;
|
||||
VkPipelineRasterizationDepthClipStateCreateInfoEXT *dc =
|
||||
vkb_emu_chain_take(rs, VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_DEPTH_CLIP_STATE_CREATE_INFO_EXT);
|
||||
if (dc) rs->depthClampEnable = dc->depthClipEnable ? VK_FALSE : VK_TRUE;
|
||||
}
|
||||
|
||||
void vkb_emu_depth_clip_install(vkb_srv_table *dev)
|
||||
{
|
||||
(void)dev;
|
||||
}
|
||||
Reference in new issue
Block a user