Avoid initializing Shader::PsColorBuffer in RefreshGraphicsKey (#3799)

The bitfield in the struct is padded, which produces uninitialized memory on initialization.
To avoid modifying the struct while making our GraphicsPipelineKey struct properly hashable, set values directly instead of re-initializing.

This fixes pipeline compile spam, and the subsequent poor performance, on certain setups.
This commit is contained in:
Stephen Miller
2025-11-14 21:50:14 -06:00
committed by GitHub
parent f557c6ac64
commit 94d0f2e7ed

View File

@@ -355,13 +355,12 @@ bool PipelineCache::RefreshGraphicsKey() {
}
// Fill color target information
key.color_buffers[cb] = Shader::PsColorBuffer{
.data_format = col_buf.GetDataFmt(),
.num_format = col_buf.GetNumberFmt(),
.num_conversion = col_buf.GetNumberConversion(),
.export_format = regs.color_export_format.GetFormat(cb),
.swizzle = col_buf.Swizzle(),
};
auto& color_buffer = key.color_buffers[cb];
color_buffer.data_format = col_buf.GetDataFmt();
color_buffer.num_format = col_buf.GetNumberFmt();
color_buffer.num_conversion = col_buf.GetNumberConversion();
color_buffer.export_format = regs.color_export_format.GetFormat(cb);
color_buffer.swizzle = col_buf.Swizzle();
}
// Compile and bind shader stages
@@ -379,7 +378,7 @@ bool PipelineCache::RefreshGraphicsKey() {
continue;
}
if ((key.mrt_mask & (1u << cb)) == 0) {
key.color_buffers[cb] = {};
std::memset(&key.color_buffers[cb], 0, sizeof(Shader::PsColorBuffer));
continue;
}