mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-05 23:58:40 +00:00
final touches
This commit is contained in:
parent
611e5bc889
commit
1aeffbe101
3 changed files with 50 additions and 41 deletions
|
@ -237,7 +237,6 @@ bool PipelineCache::RefreshGraphicsKey() {
|
||||||
const bool skip_cb_binding =
|
const bool skip_cb_binding =
|
||||||
regs.color_control.mode == AmdGpu::Liverpool::ColorControl::OperationMode::Disable;
|
regs.color_control.mode == AmdGpu::Liverpool::ColorControl::OperationMode::Disable;
|
||||||
|
|
||||||
const auto& BindColorBuffers = [&](u32 mrt_mask) {
|
|
||||||
// `RenderingInfo` is assumed to be initialized with a contiguous array of valid color
|
// `RenderingInfo` is assumed to be initialized with a contiguous array of valid color
|
||||||
// attachments. This might be not a case as HW color buffers can be bound in an arbitrary
|
// attachments. This might be not a case as HW color buffers can be bound in an arbitrary
|
||||||
// order. We need to do some arrays compaction at this stage
|
// order. We need to do some arrays compaction at this stage
|
||||||
|
@ -246,15 +245,13 @@ bool PipelineCache::RefreshGraphicsKey() {
|
||||||
key.write_masks.fill({});
|
key.write_masks.fill({});
|
||||||
key.mrt_swizzles.fill(Liverpool::ColorBuffer::SwapMode::Standard);
|
key.mrt_swizzles.fill(Liverpool::ColorBuffer::SwapMode::Standard);
|
||||||
|
|
||||||
int remapped_cb{};
|
// First pass of bindings check to idenitfy formats and swizzles and pass them to rhe shader
|
||||||
for (auto cb = 0u; cb < Liverpool::NumColorBuffers; ++cb) {
|
// recompiler.
|
||||||
|
for (auto cb = 0u, remapped_cb = 0u; cb < Liverpool::NumColorBuffers; ++cb) {
|
||||||
auto const& col_buf = regs.color_buffers[cb];
|
auto const& col_buf = regs.color_buffers[cb];
|
||||||
if (skip_cb_binding || !col_buf || !regs.color_target_mask.GetMask(cb)) {
|
if (skip_cb_binding || !col_buf || !regs.color_target_mask.GetMask(cb)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((mrt_mask & (1u << cb)) == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const auto base_format =
|
const auto base_format =
|
||||||
LiverpoolToVK::SurfaceFormat(col_buf.info.format, col_buf.NumFormat());
|
LiverpoolToVK::SurfaceFormat(col_buf.info.format, col_buf.NumFormat());
|
||||||
const bool is_vo_surface = renderer->IsVideoOutSurface(col_buf);
|
const bool is_vo_surface = renderer->IsVideoOutSurface(col_buf);
|
||||||
|
@ -263,19 +260,9 @@ bool PipelineCache::RefreshGraphicsKey() {
|
||||||
if (base_format == key.color_formats[remapped_cb]) {
|
if (base_format == key.color_formats[remapped_cb]) {
|
||||||
key.mrt_swizzles[remapped_cb] = col_buf.info.comp_swap.Value();
|
key.mrt_swizzles[remapped_cb] = col_buf.info.comp_swap.Value();
|
||||||
}
|
}
|
||||||
key.blend_controls[remapped_cb] = regs.blend_control[cb];
|
|
||||||
key.blend_controls[remapped_cb].enable.Assign(key.blend_controls[remapped_cb].enable &&
|
|
||||||
!col_buf.info.blend_bypass);
|
|
||||||
key.write_masks[remapped_cb] =
|
|
||||||
vk::ColorComponentFlags{regs.color_target_mask.GetMask(cb)};
|
|
||||||
key.cb_shader_mask.SetMask(remapped_cb, regs.color_shader_mask.GetMask(cb));
|
|
||||||
|
|
||||||
++remapped_cb;
|
++remapped_cb;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
// We need to run CB binding twice as actual MRT exports are unknown before FS is compiled.
|
|
||||||
BindColorBuffers(0xff);
|
|
||||||
|
|
||||||
u32 binding{};
|
u32 binding{};
|
||||||
for (u32 i = 0; i < MaxShaderStages; i++) {
|
for (u32 i = 0; i < MaxShaderStages; i++) {
|
||||||
|
@ -322,8 +309,25 @@ bool PipelineCache::RefreshGraphicsKey() {
|
||||||
|
|
||||||
const auto* fs_info = infos[u32(Shader::Stage::Fragment)];
|
const auto* fs_info = infos[u32(Shader::Stage::Fragment)];
|
||||||
key.mrt_mask = fs_info ? fs_info->mrt_mask : 0u;
|
key.mrt_mask = fs_info ? fs_info->mrt_mask : 0u;
|
||||||
BindColorBuffers(key.mrt_mask);
|
|
||||||
|
|
||||||
|
// Second pass to fill remain CB pipeline key data
|
||||||
|
for (auto cb = 0u, remapped_cb = 0u; cb < Liverpool::NumColorBuffers; ++cb) {
|
||||||
|
auto const& col_buf = regs.color_buffers[cb];
|
||||||
|
if (skip_cb_binding || !col_buf || !regs.color_target_mask.GetMask(cb) ||
|
||||||
|
(key.mrt_mask & (1u << cb)) == 0) {
|
||||||
|
key.color_formats[cb] = vk::Format::eUndefined;
|
||||||
|
key.mrt_swizzles[cb] = Liverpool::ColorBuffer::SwapMode::Standard;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
key.blend_controls[remapped_cb] = regs.blend_control[cb];
|
||||||
|
key.blend_controls[remapped_cb].enable.Assign(key.blend_controls[remapped_cb].enable &&
|
||||||
|
!col_buf.info.blend_bypass);
|
||||||
|
key.write_masks[remapped_cb] = vk::ColorComponentFlags{regs.color_target_mask.GetMask(cb)};
|
||||||
|
key.cb_shader_mask.SetMask(remapped_cb, regs.color_shader_mask.GetMask(cb));
|
||||||
|
|
||||||
|
++remapped_cb;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -213,7 +213,9 @@ boost::container::small_vector<vk::ImageMemoryBarrier2, 32> Image::GetBarriers(
|
||||||
for (u32 layer : layers) {
|
for (u32 layer : layers) {
|
||||||
// NOTE: these loops may produce a lot of small barriers.
|
// NOTE: these loops may produce a lot of small barriers.
|
||||||
// If this becomes a problem, we can optimize it by merging adjacent barriers.
|
// If this becomes a problem, we can optimize it by merging adjacent barriers.
|
||||||
auto& state = subresource_states[mip * info.resources.layers + layer];
|
const auto subres_idx = mip * info.resources.layers + layer;
|
||||||
|
ASSERT(subres_idx < subresource_states.size());
|
||||||
|
auto& state = subresource_states[subres_idx];
|
||||||
|
|
||||||
if (state.layout != dst_layout || state.access_mask != dst_mask) {
|
if (state.layout != dst_layout || state.access_mask != dst_mask) {
|
||||||
barriers.emplace_back(vk::ImageMemoryBarrier2{
|
barriers.emplace_back(vk::ImageMemoryBarrier2{
|
||||||
|
|
|
@ -87,8 +87,7 @@ ImageId TextureCache::ResolveDepthOverlap(const ImageInfo& requested_info, Image
|
||||||
auto new_image_id = slot_images.insert(instance, scheduler, requested_info);
|
auto new_image_id = slot_images.insert(instance, scheduler, requested_info);
|
||||||
RegisterImage(new_image_id);
|
RegisterImage(new_image_id);
|
||||||
|
|
||||||
// auto& new_image = slot_images[new_image_id];
|
// TODO: perform a depth copy here
|
||||||
// TODO: need to run a helper for depth copy here
|
|
||||||
|
|
||||||
FreeImage(cache_image_id);
|
FreeImage(cache_image_id);
|
||||||
return new_image_id;
|
return new_image_id;
|
||||||
|
@ -98,7 +97,11 @@ ImageId TextureCache::ResolveDepthOverlap(const ImageInfo& requested_info, Image
|
||||||
!requested_info.usage.depth_target &&
|
!requested_info.usage.depth_target &&
|
||||||
(requested_info.usage.texture || requested_info.usage.storage);
|
(requested_info.usage.texture || requested_info.usage.storage);
|
||||||
if (cache_info.usage.depth_target && should_bind_as_texture) {
|
if (cache_info.usage.depth_target && should_bind_as_texture) {
|
||||||
|
if (cache_info.resources == requested_info.resources) {
|
||||||
return cache_image_id;
|
return cache_image_id;
|
||||||
|
} else {
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue