[Vulkan] Ensure descriptor sets always initialized for user_clip_planes

This commit is contained in:
Herman S.
2025-10-27 18:42:50 +09:00
parent f13ee6ec38
commit 75589de0a4

View File

@@ -4475,27 +4475,32 @@ bool VulkanCommandProcessor::UpdateBindings(const VulkanShader* vertex_shader,
UINT32_C(1) << SpirvShaderTranslator::kConstantBufferSystem; UINT32_C(1) << SpirvShaderTranslator::kConstantBufferSystem;
} }
// Clip plane constants. // Clip plane constants.
auto pa_cl_clip_cntl = regs.Get<reg::PA_CL_CLIP_CNTL>(); // Always initialize the buffer info, even if clip planes are disabled,
bool clip_planes_enabled = // because the descriptor set write always includes all constant buffers.
!pa_cl_clip_cntl.clip_disable && pa_cl_clip_cntl.ucp_ena; if (!(current_constant_buffers_up_to_date_ &
if (clip_planes_enabled) { (UINT32_C(1) << SpirvShaderTranslator::kConstantBufferClipPlanes))) {
if (!(current_constant_buffers_up_to_date_ & VkDescriptorBufferInfo& buffer_info = current_constant_buffer_infos_
(UINT32_C(1) [SpirvShaderTranslator::kConstantBufferClipPlanes];
<< SpirvShaderTranslator::kConstantBufferClipPlanes))) { uint8_t* mapping = uniform_buffer_pool_->Request(
VkDescriptorBufferInfo& buffer_info = current_constant_buffer_infos_ frame_current_, sizeof(SpirvShaderTranslator::ClipPlaneConstants),
[SpirvShaderTranslator::kConstantBufferClipPlanes]; uniform_buffer_alignment, buffer_info.buffer, buffer_info.offset);
uint8_t* mapping = uniform_buffer_pool_->Request( if (!mapping) {
frame_current_, sizeof(SpirvShaderTranslator::ClipPlaneConstants), return false;
uniform_buffer_alignment, buffer_info.buffer, buffer_info.offset); }
if (!mapping) { buffer_info.range = sizeof(SpirvShaderTranslator::ClipPlaneConstants);
return false; auto pa_cl_clip_cntl = regs.Get<reg::PA_CL_CLIP_CNTL>();
} bool clip_planes_enabled =
buffer_info.range = sizeof(SpirvShaderTranslator::ClipPlaneConstants); !pa_cl_clip_cntl.clip_disable && pa_cl_clip_cntl.ucp_ena;
if (clip_planes_enabled) {
std::memcpy(mapping, &clip_plane_constants_, std::memcpy(mapping, &clip_plane_constants_,
sizeof(SpirvShaderTranslator::ClipPlaneConstants)); sizeof(SpirvShaderTranslator::ClipPlaneConstants));
current_constant_buffers_up_to_date_ |= } else {
UINT32_C(1) << SpirvShaderTranslator::kConstantBufferClipPlanes; // Zero out the buffer when clip planes are disabled
std::memset(mapping, 0,
sizeof(SpirvShaderTranslator::ClipPlaneConstants));
} }
current_constant_buffers_up_to_date_ |=
UINT32_C(1) << SpirvShaderTranslator::kConstantBufferClipPlanes;
} }
// Vertex shader float constants. // Vertex shader float constants.
if (!(current_constant_buffers_up_to_date_ & if (!(current_constant_buffers_up_to_date_ &