mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-08 12:49:11 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user