mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-10 05:38:49 +00:00
shader_recompiler: Implement shader export formats. (#2226)
This commit is contained in:
@@ -266,6 +266,10 @@ struct Liverpool {
|
||||
BitField<20, 4, ShaderExportFormat> col5;
|
||||
BitField<24, 4, ShaderExportFormat> col6;
|
||||
BitField<28, 4, ShaderExportFormat> col7;
|
||||
|
||||
[[nodiscard]] ShaderExportFormat GetFormat(const u32 buf_idx) const {
|
||||
return static_cast<ShaderExportFormat>((raw >> (buf_idx * 4)) & 0xfu);
|
||||
}
|
||||
};
|
||||
|
||||
union VsOutputControl {
|
||||
|
||||
@@ -35,9 +35,8 @@ struct GraphicsPipelineKey {
|
||||
std::array<size_t, MaxShaderStages> stage_hashes;
|
||||
u32 num_color_attachments;
|
||||
std::array<vk::Format, Liverpool::NumColorBuffers> color_formats;
|
||||
std::array<AmdGpu::NumberFormat, Liverpool::NumColorBuffers> color_num_formats;
|
||||
std::array<AmdGpu::NumberConversion, Liverpool::NumColorBuffers> color_num_conversions;
|
||||
std::array<AmdGpu::CompMapping, Liverpool::NumColorBuffers> color_swizzles;
|
||||
std::array<Shader::FragmentRuntimeInfo::PsColorBuffer, Liverpool::NumColorBuffers>
|
||||
color_buffers;
|
||||
vk::Format depth_format;
|
||||
vk::Format stencil_format;
|
||||
|
||||
|
||||
@@ -167,11 +167,7 @@ const Shader::RuntimeInfo& PipelineCache::BuildRuntimeInfo(Stage stage, LogicalS
|
||||
};
|
||||
}
|
||||
for (u32 i = 0; i < Shader::MaxColorBuffers; i++) {
|
||||
info.fs_info.color_buffers[i] = {
|
||||
.num_format = graphics_key.color_num_formats[i],
|
||||
.num_conversion = graphics_key.color_num_conversions[i],
|
||||
.swizzle = graphics_key.color_swizzles[i],
|
||||
};
|
||||
info.fs_info.color_buffers[i] = graphics_key.color_buffers[i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -309,11 +305,9 @@ bool PipelineCache::RefreshGraphicsKey() {
|
||||
// order. We need to do some arrays compaction at this stage
|
||||
key.num_color_attachments = 0;
|
||||
key.color_formats.fill(vk::Format::eUndefined);
|
||||
key.color_num_formats.fill(AmdGpu::NumberFormat::Unorm);
|
||||
key.color_num_conversions.fill(AmdGpu::NumberConversion::None);
|
||||
key.color_buffers.fill({});
|
||||
key.blend_controls.fill({});
|
||||
key.write_masks.fill({});
|
||||
key.color_swizzles.fill({});
|
||||
key.vertex_buffer_formats.fill(vk::Format::eUndefined);
|
||||
|
||||
key.patch_control_points = 0;
|
||||
@@ -338,9 +332,12 @@ bool PipelineCache::RefreshGraphicsKey() {
|
||||
|
||||
key.color_formats[remapped_cb] =
|
||||
LiverpoolToVK::SurfaceFormat(col_buf.GetDataFmt(), col_buf.GetNumberFmt());
|
||||
key.color_num_formats[remapped_cb] = col_buf.GetNumberFmt();
|
||||
key.color_num_conversions[remapped_cb] = col_buf.GetNumberConversion();
|
||||
key.color_swizzles[remapped_cb] = col_buf.Swizzle();
|
||||
key.color_buffers[remapped_cb] = {
|
||||
.num_format = col_buf.GetNumberFmt(),
|
||||
.num_conversion = col_buf.GetNumberConversion(),
|
||||
.swizzle = col_buf.Swizzle(),
|
||||
.export_format = regs.color_export_format.GetFormat(cb),
|
||||
};
|
||||
}
|
||||
|
||||
fetch_shader = std::nullopt;
|
||||
@@ -456,7 +453,7 @@ bool PipelineCache::RefreshGraphicsKey() {
|
||||
// of the latter we need to change format to undefined, and either way we need to
|
||||
// increment the index for the null attachment binding.
|
||||
key.color_formats[remapped_cb] = vk::Format::eUndefined;
|
||||
key.color_swizzles[remapped_cb] = {};
|
||||
key.color_buffers[remapped_cb] = {};
|
||||
++remapped_cb;
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user