Files
DroidDeck/tools/gamescope/patches/0130-composite-without-immutable-ycbcr-samplers.patch
T
The412Banner 556e6b4185 Non-Adreno round 4: Mali GPU-drawing block, gamescope YCbCr retry, GL probe, bridge draw sync
- Setup's "Steam interface: GPU drawing" is hidden on Mali and a saved "on" is
  cleared: with PanVK it rebooted an Edge 60 (G615) as steamwebhelper started.
  Kept for Xclipse.
- gamescope 0130: a composite pipeline refused at start-up is retried with a
  layout without immutable YCbCr samplers (G615 through Venus refused every
  composite shader; their SPIR-V has no Float16, so fp16 was not the cause).
- Venus: droiddeck-glprobe opens GL through GLX the way the Steam client does,
  with the loader's reasons logged; when it fails the client's GL goes to
  llvmpipe.
- vkbridge self-test: the draw check waits for the render pass's stores before
  copying out (a tiler read zeros without the dependency).
2026-10-13 09:27:50 -04:00

79 lines
3.7 KiB
Diff

diff --git a/src/rendervulkan.cpp b/src/rendervulkan.cpp
index 103baee..d344a99 100644
--- a/src/rendervulkan.cpp
+++ b/src/rendervulkan.cpp
@@ -319,6 +319,33 @@ bool CVulkanDevice::BInit(VkInstance instance, VkSurfaceKHR surface)
return false;
if (!createShaders())
return false;
+ {
+ // One composite pipeline up front: a driver that refuses it with the immutable YCbCr
+ // samplers gets the layout without them (NV12 textures then sample without conversion).
+ if ( getenv( "GAMESCOPE_NO_YCBCR_SAMPLERS" ) && *getenv( "GAMESCOPE_NO_YCBCR_SAMPLERS" ) == '1' )
+ {
+ vk_log.infof( "GAMESCOPE_NO_YCBCR_SAMPLERS=1: composite layout without immutable YCbCr samplers" );
+ vk.DestroyPipelineLayout( device(), m_pipelineLayout, nullptr );
+ vk.DestroyDescriptorSetLayout( device(), m_descriptorSetLayout, nullptr );
+ m_bYcbcrImmutableSamplers = false;
+ if ( !createLayouts() )
+ return false;
+ }
+ VkPipeline probe = compilePipeline( 1, 0, SHADER_TYPE_BLIT, 1, 0, 0, 0, false );
+ if ( probe == VK_NULL_HANDLE && m_bYcbcrImmutableSamplers )
+ {
+ vk_log.errorf( "composite pipeline refused; retrying without immutable YCbCr samplers" );
+ vk.DestroyPipelineLayout( device(), m_pipelineLayout, nullptr );
+ vk.DestroyDescriptorSetLayout( device(), m_descriptorSetLayout, nullptr );
+ m_bYcbcrImmutableSamplers = false;
+ if ( !createLayouts() )
+ return false;
+ probe = compilePipeline( 1, 0, SHADER_TYPE_BLIT, 1, 0, 0, 0, false );
+ vk_log.infof( "composite pipeline without immutable YCbCr samplers: %s", probe ? "accepted" : "STILL refused" );
+ }
+ if ( probe != VK_NULL_HANDLE )
+ vk.DestroyPipeline( device(), probe, nullptr );
+ }
if (!createScratchResources())
return false;
@@ -869,7 +896,7 @@ bool CVulkanDevice::createLayouts()
.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
.descriptorCount = VKR_SAMPLER_SLOTS,
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
- .pImmutableSamplers = ycbcrSamplers.data(),
+ .pImmutableSamplers = m_bYcbcrImmutableSamplers ? ycbcrSamplers.data() : nullptr,
},
VkDescriptorSetLayoutBinding {
.binding = 5,
@@ -1870,6 +1897,8 @@ void CVulkanCmdBuffer::dispatch(uint32_t x, uint32_t y, uint32_t z)
imageDescriptors[i].sampler = m_device->sampler(m_samplerState[i]);
imageDescriptors[i].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
ycbcrImageDescriptors[i].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
+ if ( !m_device->ycbcrImmutableSamplers() )
+ ycbcrImageDescriptors[i].sampler = imageDescriptors[i].sampler;
if (m_boundTextures[i] == nullptr)
continue;
diff --git a/src/rendervulkan.hpp b/src/rendervulkan.hpp
index 901e6a6..e0ede11 100644
--- a/src/rendervulkan.hpp
+++ b/src/rendervulkan.hpp
@@ -876,6 +876,7 @@ public:
inline bool hasDrmPrimaryDevId() {return m_bHasDrmPrimaryDevId;}
inline dev_t primaryDevId() {return m_drmPrimaryDevId;}
inline bool supportsFp16() {return m_bSupportsFp16;}
+ inline bool ycbcrImmutableSamplers() {return m_bYcbcrImmutableSamplers;}
inline std::vector<VkExtensionProperties>& supportedExtensions() {return m_supportedExts;}
inline std::pair<void *, uint32_t> uploadBufferData(uint32_t size)
@@ -925,6 +926,9 @@ protected:
VkQueue m_generalQueue = nullptr;
VkSamplerYcbcrConversion m_ycbcrConversion = VK_NULL_HANDLE;
VkSampler m_ycbcrSampler = VK_NULL_HANDLE;
+ // Binding 4 carries immutable YCbCr samplers; off when the driver refuses every composite
+ // pipeline with them (Mali-G615 through Venus: VK_ERROR_INITIALIZATION_FAILED).
+ bool m_bYcbcrImmutableSamplers = true;
VkDescriptorSetLayout m_descriptorSetLayout = VK_NULL_HANDLE;
VkPipelineLayout m_pipelineLayout = VK_NULL_HANDLE;
VkDescriptorPool m_descriptorPool = VK_NULL_HANDLE;