From 1b06bef3353353d2a254a4ddf6b831087ab8320f Mon Sep 17 00:00:00 2001 From: izzy2lost Date: Mon, 30 Mar 2026 12:11:52 -0400 Subject: [PATCH] Fix Vulkan direct surface binding after Android texture conversion --- hw/xbox/nv2a/pgraph/vk/texture.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/hw/xbox/nv2a/pgraph/vk/texture.c b/hw/xbox/nv2a/pgraph/vk/texture.c index 1971f2f705..d37ea371dc 100644 --- a/hw/xbox/nv2a/pgraph/vk/texture.c +++ b/hw/xbox/nv2a/pgraph/vk/texture.c @@ -1274,6 +1274,16 @@ static bool color_surface_can_direct_bind(const SurfaceBinding *surface, surface->host_fmt.vk_format == tex_vkf.vk_format; } +static bool surface_can_direct_bind(const SurfaceBinding *surface, + const TextureBinding *texture) +{ + if (surface->color) { + return color_surface_can_direct_bind(surface, texture); + } + + return !(surface->host_fmt.aspect & VK_IMAGE_ASPECT_STENCIL_BIT); +} + static VkImageView get_surface_direct_texture_view(PGRAPHVkState *r, SurfaceBinding *surface, TextureBinding *texture) @@ -1773,9 +1783,7 @@ static void create_texture(PGRAPHState *pg, int texture_idx) if (binding_found) { if (surface_to_texture) { - bool can_direct_bind = - color_surface_can_direct_bind(surface, snode) || - !(surface->host_fmt.aspect & VK_IMAGE_ASPECT_STENCIL_BIT); + bool can_direct_bind = surface_can_direct_bind(surface, snode); if (can_direct_bind) { VkImageLayout direct_layout; if (surface->color) { @@ -2008,9 +2016,7 @@ static void create_texture(PGRAPHState *pg, int texture_idx) r->texture_bindings[texture_idx] = snode; if (surface_to_texture) { - bool can_direct_bind = - color_surface_can_direct_bind(surface, snode) || - !(surface->host_fmt.aspect & VK_IMAGE_ASPECT_STENCIL_BIT); + bool can_direct_bind = surface_can_direct_bind(surface, snode); if (can_direct_bind) { VkImageLayout direct_layout; if (surface->color) {