mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 22:06:59 +01:00
format source files
This commit is contained in:
@@ -4,13 +4,17 @@
|
||||
// #error "KYTY_PLATFORM != KYTY_PLATFORM_WINDOWS"
|
||||
#else
|
||||
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#include <windows.h> // IWYU pragma: keep
|
||||
|
||||
#include "common/platform/sysFileIO.h"
|
||||
#include "common/platform/sysTimer.h"
|
||||
#include "common/stringUtils.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <vector>
|
||||
#include <windows.h> // IWYU pragma: keep
|
||||
|
||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||
enum sys_file_type_t {
|
||||
|
||||
@@ -4,12 +4,15 @@
|
||||
// #error "KYTY_PLATFORM != KYTY_PLATFORM_WINDOWS"
|
||||
#else
|
||||
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#include <windows.h> // IWYU pragma: keep
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/platform/sysVirtual.h"
|
||||
#include "common/virtualMemory.h"
|
||||
|
||||
#include <windows.h> // IWYU pragma: keep
|
||||
|
||||
// IWYU pragma: no_include <basetsd.h>
|
||||
// IWYU pragma: no_include <errhandlingapi.h>
|
||||
// IWYU pragma: no_include <memoryapi.h>
|
||||
|
||||
@@ -28,8 +28,8 @@ constexpr FormatInfo kFormatInfo[] = {
|
||||
{GpuEnumValue(BufferFormat::k16_16UInt), VK_FORMAT_R16G16_UINT, 4, 0, 4, true, true},
|
||||
{GpuEnumValue(BufferFormat::k16_16SInt), VK_FORMAT_R16G16_SINT, 4, 0, 4, false, false},
|
||||
{GpuEnumValue(BufferFormat::k16_16Float), VK_FORMAT_R16G16_SFLOAT, 4, 0, 4, true, false},
|
||||
{GpuEnumValue(BufferFormat::k11_11_10Float), VK_FORMAT_B10G11R11_UFLOAT_PACK32, 4, 0, 4,
|
||||
true, false},
|
||||
{GpuEnumValue(BufferFormat::k11_11_10Float), VK_FORMAT_B10G11R11_UFLOAT_PACK32, 4, 0, 4, true,
|
||||
false},
|
||||
{GpuEnumValue(BufferFormat::k10_10_10_2UNorm), VK_FORMAT_A2B10G10R10_UNORM_PACK32, 4, 0, 4,
|
||||
true, false},
|
||||
{GpuEnumValue(BufferFormat::k8_8_8_8UNorm), VK_FORMAT_R8G8B8A8_UNORM, 4, 0, 4, true, false},
|
||||
@@ -50,28 +50,25 @@ constexpr FormatInfo kFormatInfo[] = {
|
||||
{GpuEnumValue(BufferFormat::k16_16_16_16Float), VK_FORMAT_R16G16B16A16_SFLOAT, 8, 0, 8, true,
|
||||
false},
|
||||
{GpuEnumValue(BufferFormat::k32_32_32UInt), VK_FORMAT_R32G32B32_UINT, 12, 0, 12, true, true},
|
||||
{GpuEnumValue(BufferFormat::k32_32_32SInt), VK_FORMAT_R32G32B32_SINT, 12, 0, 12, false,
|
||||
false},
|
||||
{GpuEnumValue(BufferFormat::k32_32_32SInt), VK_FORMAT_R32G32B32_SINT, 12, 0, 12, false, false},
|
||||
{GpuEnumValue(BufferFormat::k32_32_32Float), VK_FORMAT_R32G32B32_SFLOAT, 12, 0, 12, true,
|
||||
false},
|
||||
{GpuEnumValue(BufferFormat::k32_32_32_32UInt), VK_FORMAT_R32G32B32A32_UINT, 16, 0, 16, true,
|
||||
true},
|
||||
{GpuEnumValue(BufferFormat::k32_32_32_32SInt), VK_FORMAT_R32G32B32A32_SINT, 16, 0, 16, false,
|
||||
false},
|
||||
{GpuEnumValue(BufferFormat::k32_32_32_32Float), VK_FORMAT_R32G32B32A32_SFLOAT, 16, 0, 16,
|
||||
true, false},
|
||||
{GpuEnumValue(BufferFormat::k32_32_32_32Float), VK_FORMAT_R32G32B32A32_SFLOAT, 16, 0, 16, true,
|
||||
false},
|
||||
{GpuEnumValue(BufferFormat::k8_8_8_8Srgb), VK_FORMAT_R8G8B8A8_SRGB, 4, 0, 4, true, false},
|
||||
{GpuEnumValue(BufferFormat::k9_9_9_5Float), VK_FORMAT_E5B9G9R9_UFLOAT_PACK32, 4, 0, 0, true,
|
||||
false},
|
||||
{GpuEnumValue(BufferFormat::k5_6_5UNorm), VK_FORMAT_B5G6R5_UNORM_PACK16, 2, 0, 2, true,
|
||||
false},
|
||||
{GpuEnumValue(BufferFormat::k5_6_5UNorm), VK_FORMAT_B5G6R5_UNORM_PACK16, 2, 0, 2, true, false},
|
||||
{GpuEnumValue(BufferFormat::k5_5_5_1UNorm), VK_FORMAT_R5G5B5A1_UNORM_PACK16, 2, 0, 2, true,
|
||||
false},
|
||||
{GpuEnumValue(BufferFormat::k4_4_4_4UNorm), VK_FORMAT_R4G4B4A4_UNORM_PACK16, 2, 0, 2, true,
|
||||
false},
|
||||
{GpuEnumValue(BufferFormat::kFmask8_S4_F4), VK_FORMAT_R32_SFLOAT, 1, 0, 1, true, false},
|
||||
{GpuEnumValue(BufferFormat::kBc1UNorm), VK_FORMAT_BC1_RGBA_UNORM_BLOCK, 0, 8, 0, true,
|
||||
false},
|
||||
{GpuEnumValue(BufferFormat::kBc1UNorm), VK_FORMAT_BC1_RGBA_UNORM_BLOCK, 0, 8, 0, true, false},
|
||||
{GpuEnumValue(BufferFormat::kBc1Srgb), VK_FORMAT_BC1_RGBA_SRGB_BLOCK, 0, 8, 0, true, false},
|
||||
{GpuEnumValue(BufferFormat::kBc2UNorm), VK_FORMAT_BC2_UNORM_BLOCK, 0, 16, 0, true, false},
|
||||
{GpuEnumValue(BufferFormat::kBc2Srgb), VK_FORMAT_BC2_SRGB_BLOCK, 0, 16, 0, true, false},
|
||||
|
||||
@@ -1526,9 +1526,7 @@ void CommandProcessor::WriteAtEndOfPipe(uint32_t cache_policy, uint32_t event_wr
|
||||
switch (interrupt_selector) {
|
||||
case 0x00:
|
||||
case 0x03: with_interrupt = false; break;
|
||||
case 0x01:
|
||||
Sync::TriggerEopEventAtEndOfPipe(CurrentBuffer(), interrupt_context_id);
|
||||
return;
|
||||
case 0x01: Sync::TriggerEopEventAtEndOfPipe(CurrentBuffer(), interrupt_context_id); return;
|
||||
case 0x02: with_interrupt = true; break;
|
||||
default: EXIT("unknown interrupt_selector\n");
|
||||
}
|
||||
@@ -1540,11 +1538,11 @@ void CommandProcessor::WriteAtEndOfPipe(uint32_t cache_policy, uint32_t event_wr
|
||||
|
||||
if (with_interrupt) {
|
||||
if (with_writeback) {
|
||||
Sync::WriteAtEndOfPipeWithInterruptWriteBack32(
|
||||
m_submit_id, CurrentBuffer(), dst, data, interrupt_context_id);
|
||||
} else {
|
||||
Sync::WriteAtEndOfPipeWithInterrupt32(m_submit_id, CurrentBuffer(), dst,
|
||||
Sync::WriteAtEndOfPipeWithInterruptWriteBack32(m_submit_id, CurrentBuffer(), dst,
|
||||
data, interrupt_context_id);
|
||||
} else {
|
||||
Sync::WriteAtEndOfPipeWithInterrupt32(m_submit_id, CurrentBuffer(), dst, data,
|
||||
interrupt_context_id);
|
||||
}
|
||||
} else if (with_writeback) {
|
||||
Sync::WriteAtEndOfPipeWithWriteBack32(m_submit_id, CurrentBuffer(), dst, data);
|
||||
@@ -1560,8 +1558,8 @@ void CommandProcessor::WriteAtEndOfPipe(uint32_t cache_policy, uint32_t event_wr
|
||||
auto* dst = static_cast<uint32_t*>(dst_gpu_addr);
|
||||
SynchronizeGpu();
|
||||
Sync::ReadGds(dst, value & 0xffffu, value >> 16u);
|
||||
Sync::WriteAtEndOfPipeGds32(m_submit_id, CurrentBuffer(), dst,
|
||||
value & 0xffffu, value >> 16u);
|
||||
Sync::WriteAtEndOfPipeGds32(m_submit_id, CurrentBuffer(), dst, value & 0xffffu,
|
||||
value >> 16u);
|
||||
return;
|
||||
}
|
||||
} else if (eop_event_type == 0x04 && cache_action == 0x00 && event_index == 0x05) {
|
||||
@@ -1588,12 +1586,12 @@ void CommandProcessor::WriteAtEndOfPipe(uint32_t cache_policy, uint32_t event_wr
|
||||
Sync::WriteAtEndOfPipeWithInterruptWriteBack64(
|
||||
m_submit_id, CurrentBuffer(), dst, value, interrupt_context_id);
|
||||
} else {
|
||||
Sync::WriteAtEndOfPipeWithInterrupt64(
|
||||
m_submit_id, CurrentBuffer(), dst, value, interrupt_context_id);
|
||||
Sync::WriteAtEndOfPipeWithInterrupt64(m_submit_id, CurrentBuffer(), dst,
|
||||
value, interrupt_context_id);
|
||||
}
|
||||
} else if (with_writeback) {
|
||||
Sync::WriteAtEndOfPipeWithWriteBack64(m_submit_id, CurrentBuffer(),
|
||||
dst, value);
|
||||
Sync::WriteAtEndOfPipeWithWriteBack64(m_submit_id, CurrentBuffer(), dst,
|
||||
value);
|
||||
} else {
|
||||
Sync::WriteAtEndOfPipe64(m_submit_id, CurrentBuffer(), dst, value);
|
||||
}
|
||||
@@ -1669,8 +1667,8 @@ void CommandProcessor::WriteAtEndOfPipe(uint32_t cache_policy, uint32_t event_wr
|
||||
if (((eop_event_type == 0x04 && event_index == 0x05) ||
|
||||
(eop_event_type == 0x28 && event_index == 0x00)) &&
|
||||
!with_interrupt) {
|
||||
Sync::WriteAtEndOfPipeClockCounter(
|
||||
m_submit_id, CurrentBuffer(), static_cast<uint64_t*>(dst_gpu_addr),
|
||||
Sync::WriteAtEndOfPipeClockCounter(m_submit_id, CurrentBuffer(),
|
||||
static_cast<uint64_t*>(dst_gpu_addr),
|
||||
clock);
|
||||
return;
|
||||
}
|
||||
@@ -1837,9 +1835,9 @@ void CommandProcessor::Flip(void* dst_gpu_addr, uint32_t value) {
|
||||
auto* command = CurrentBuffer();
|
||||
auto request = Sync::PrepareDisplayBufferFlip(command, m_flip.handle, m_flip.index,
|
||||
m_flip.flip_mode, m_flip.flip_arg);
|
||||
Sync::WriteAtEndOfPipeWithFlip32(
|
||||
m_submit_id, command, static_cast<uint32_t*>(dst_gpu_addr), value, m_flip.handle,
|
||||
m_flip.index, m_flip.flip_mode, m_flip.flip_arg, request);
|
||||
Sync::WriteAtEndOfPipeWithFlip32(m_submit_id, command, static_cast<uint32_t*>(dst_gpu_addr),
|
||||
value, m_flip.handle, m_flip.index, m_flip.flip_mode,
|
||||
m_flip.flip_arg, request);
|
||||
m_scheduler.Flush();
|
||||
}
|
||||
|
||||
|
||||
@@ -299,8 +299,7 @@ static bool Gen5Standard64KBLayout(uint32_t format, uint32_t* bytes_per_element,
|
||||
}
|
||||
}
|
||||
|
||||
static bool Gen5Thin64KBBlockSizeFromElementBytes(uint32_t bytes_per_element,
|
||||
uint32_t* block_width,
|
||||
static bool Gen5Thin64KBBlockSizeFromElementBytes(uint32_t bytes_per_element, uint32_t* block_width,
|
||||
uint32_t* block_height) {
|
||||
// AGC thin 64 KiB block table, shared by depth and render-target tiles.
|
||||
switch (bytes_per_element) {
|
||||
@@ -1181,8 +1180,8 @@ static void ConvertRenderTargetTyped(uint32_t width, uint32_t height, uint32_t p
|
||||
|
||||
uint32_t block_width = 0;
|
||||
uint32_t block_height = 0;
|
||||
EXIT_NOT_IMPLEMENTED(!Gen5Thin64KBBlockSizeFromElementBytes(
|
||||
static_cast<uint32_t>(sizeof(T)), &block_width, &block_height));
|
||||
EXIT_NOT_IMPLEMENTED(!Gen5Thin64KBBlockSizeFromElementBytes(static_cast<uint32_t>(sizeof(T)),
|
||||
&block_width, &block_height));
|
||||
|
||||
const uint64_t blocks_per_row = (static_cast<uint64_t>(pitch) + block_width - 1u) / block_width;
|
||||
const uint32_t block_columns = (width == 0 ? 0 : 1u + (width - 1u) / block_width);
|
||||
@@ -2222,14 +2221,12 @@ static void TileConvertDepth(void* dst, const void* src, uint32_t format, uint32
|
||||
const uint32_t block_width = supported_bpe && bytes_per_element <= 2 ? 256u : 128u;
|
||||
const uint32_t block_height = supported_bpe ? 65536u / (block_width * bytes_per_element) : 0;
|
||||
if (dst == nullptr || src == nullptr || width == 0 || height == 0 || pitch < width ||
|
||||
!supported_bpe || pitch % block_width != 0 ||
|
||||
size == 0 || size % 65536u != 0) {
|
||||
!supported_bpe || pitch % block_width != 0 || size == 0 || size % 65536u != 0) {
|
||||
EXIT("unsupported depth conversion, dst=%p src=%p format=%u "
|
||||
"extent=%ux%u pitch=%u size=0x%016" PRIx64 "\n",
|
||||
dst, src, format, width, height, pitch, size);
|
||||
}
|
||||
const uint64_t block_rows =
|
||||
(static_cast<uint64_t>(height) + block_height - 1u) / block_height;
|
||||
const uint64_t block_rows = (static_cast<uint64_t>(height) + block_height - 1u) / block_height;
|
||||
const uint64_t blocks_per_row = pitch / block_width;
|
||||
if (blocks_per_row > UINT64_MAX / block_rows ||
|
||||
blocks_per_row * block_rows > UINT64_MAX / 65536u ||
|
||||
@@ -2504,7 +2501,7 @@ void TileConvertLinearToTiledRenderTarget(void* dst, const void* src, uint32_t w
|
||||
KYTY_PROFILER_FUNCTION();
|
||||
const bool tail_block = dst_size != 0 && (dst_x != 0 || dst_y != 0 || size < dst_size);
|
||||
if (tail_block) {
|
||||
//Not sure about this at all
|
||||
// Not sure about this at all
|
||||
if (bytes_per_element != 8) {
|
||||
EXIT("unsupported linear-to-tiled render-target tail element size: %u\n",
|
||||
bytes_per_element);
|
||||
@@ -2596,8 +2593,8 @@ bool TileGetDepthSize(uint32_t width, uint32_t height, uint32_t pitch, uint32_t
|
||||
uint32_t TileGetRenderTargetPitch(uint32_t width, uint32_t bytes_per_element) {
|
||||
uint32_t block_width = 0;
|
||||
uint32_t block_height = 0;
|
||||
if (width == 0 || !Gen5Thin64KBBlockSizeFromElementBytes(bytes_per_element, &block_width,
|
||||
&block_height)) {
|
||||
if (width == 0 ||
|
||||
!Gen5Thin64KBBlockSizeFromElementBytes(bytes_per_element, &block_width, &block_height)) {
|
||||
return 0;
|
||||
}
|
||||
const uint64_t pitch = (static_cast<uint64_t>(width) + block_width - 1u) &
|
||||
@@ -2611,8 +2608,7 @@ bool TileGetRenderTargetSize(uint32_t width, uint32_t height, uint32_t pitch,
|
||||
uint32_t block_width = 0;
|
||||
uint32_t block_height = 0;
|
||||
if (height == 0 || pitch == 0 ||
|
||||
!Gen5Thin64KBBlockSizeFromElementBytes(bytes_per_element, &block_width,
|
||||
&block_height) ||
|
||||
!Gen5Thin64KBBlockSizeFromElementBytes(bytes_per_element, &block_width, &block_height) ||
|
||||
pitch != TileGetRenderTargetPitch(width, bytes_per_element)) {
|
||||
return false;
|
||||
}
|
||||
@@ -2655,8 +2651,8 @@ bool TileGetRenderTargetMipLayout(uint32_t width, uint32_t height, uint32_t pitc
|
||||
default: return false;
|
||||
}
|
||||
TileGetTextureSize(format, width, height, pitch, levels,
|
||||
Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget), total_size, level_sizes,
|
||||
padded_size);
|
||||
Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget), total_size,
|
||||
level_sizes, padded_size);
|
||||
return total_size->size != 0 && total_size->align == 65536;
|
||||
}
|
||||
|
||||
@@ -2738,8 +2734,8 @@ void TileGetTextureSize(uint32_t format, uint32_t width, uint32_t height, uint32
|
||||
bytes_per_element != 0 && tile == 27 && levels == 1) {
|
||||
uint32_t block_width = 0;
|
||||
uint32_t block_height = 0;
|
||||
EXIT_NOT_IMPLEMENTED(!Gen5Thin64KBBlockSizeFromElementBytes(
|
||||
bytes_per_element, &block_width, &block_height));
|
||||
EXIT_NOT_IMPLEMENTED(
|
||||
!Gen5Thin64KBBlockSizeFromElementBytes(bytes_per_element, &block_width, &block_height));
|
||||
|
||||
const uint32_t padded_width = AlignUp(pitch, block_width);
|
||||
const uint32_t padded_height = AlignUp(height, block_height);
|
||||
@@ -2767,8 +2763,8 @@ void TileGetTextureSize(uint32_t format, uint32_t width, uint32_t height, uint32
|
||||
bytes_per_element != 0 && tile == 27 && levels > 1) {
|
||||
uint32_t block_width = 0;
|
||||
uint32_t block_height = 0;
|
||||
EXIT_NOT_IMPLEMENTED(!Gen5Thin64KBBlockSizeFromElementBytes(
|
||||
bytes_per_element, &block_width, &block_height));
|
||||
EXIT_NOT_IMPLEMENTED(
|
||||
!Gen5Thin64KBBlockSizeFromElementBytes(bytes_per_element, &block_width, &block_height));
|
||||
|
||||
const uint32_t bytes_log2 = IntLog2(bytes_per_element);
|
||||
const uint32_t tail_width_limit = block_width >> 1u;
|
||||
@@ -2992,8 +2988,8 @@ void TileGetTextureSize(uint32_t format, uint32_t width, uint32_t height, uint32
|
||||
if (bytes_per_element != 0) {
|
||||
uint32_t block_width = 0;
|
||||
uint32_t block_height = 0;
|
||||
const bool supported = bytes_per_element <= 4 &&
|
||||
Gen5Thin64KBBlockSizeFromElementBytes(
|
||||
const bool supported =
|
||||
bytes_per_element <= 4 && Gen5Thin64KBBlockSizeFromElementBytes(
|
||||
bytes_per_element, &block_width, &block_height);
|
||||
|
||||
if (supported) {
|
||||
@@ -3026,8 +3022,8 @@ void TileGetTextureSize(uint32_t format, uint32_t width, uint32_t height, uint32
|
||||
if (bytes_per_element != 0) {
|
||||
uint32_t block_width = 0;
|
||||
uint32_t block_height = 0;
|
||||
const bool supported = bytes_per_element <= 4 &&
|
||||
Gen5Thin64KBBlockSizeFromElementBytes(
|
||||
const bool supported =
|
||||
bytes_per_element <= 4 && Gen5Thin64KBBlockSizeFromElementBytes(
|
||||
bytes_per_element, &block_width, &block_height);
|
||||
|
||||
if (supported) {
|
||||
@@ -3271,7 +3267,8 @@ uint32_t TileGetTexturePitch(uint32_t format, uint32_t width, uint32_t levels, u
|
||||
uint32_t pitch = width;
|
||||
|
||||
if (tile == 27) {
|
||||
if (const uint32_t bytes_per_element = Prospero::NumBytesPerElement(format); bytes_per_element != 0) {
|
||||
if (const uint32_t bytes_per_element = Prospero::NumBytesPerElement(format);
|
||||
bytes_per_element != 0) {
|
||||
uint32_t block_width = 0;
|
||||
uint32_t block_height = 0;
|
||||
EXIT_NOT_IMPLEMENTED(!Gen5Thin64KBBlockSizeFromElementBytes(
|
||||
@@ -3281,7 +3278,8 @@ uint32_t TileGetTexturePitch(uint32_t format, uint32_t width, uint32_t levels, u
|
||||
}
|
||||
|
||||
if (tile == 0) {
|
||||
if (const auto bytes_per_element = Prospero::NumBytesPerElement(format); bytes_per_element != 0) {
|
||||
if (const auto bytes_per_element = Prospero::NumBytesPerElement(format);
|
||||
bytes_per_element != 0) {
|
||||
pitch = AlignUp(pitch * bytes_per_element, 256u) / bytes_per_element;
|
||||
}
|
||||
}
|
||||
@@ -3299,8 +3297,8 @@ uint32_t TileGetTexturePitch(uint32_t format, uint32_t width, uint32_t levels, u
|
||||
const uint32_t bytes_per_element = Prospero::NumBytesPerElement(format);
|
||||
uint32_t block_width = 0;
|
||||
uint32_t block_height = 0;
|
||||
if (bytes_per_element <= 4 && Gen5Thin64KBBlockSizeFromElementBytes(
|
||||
bytes_per_element, &block_width, &block_height)) {
|
||||
if (bytes_per_element <= 4 &&
|
||||
Gen5Thin64KBBlockSizeFromElementBytes(bytes_per_element, &block_width, &block_height)) {
|
||||
pitch = AlignUp(pitch, block_width);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ thread_local bool g_in_fault_resolution = false;
|
||||
std::fputc('\n', stderr);
|
||||
#if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS
|
||||
void* frames[16] {};
|
||||
const auto frame_count = CaptureStackBackTrace(0, static_cast<DWORD>(std::size(frames)), frames,
|
||||
nullptr);
|
||||
const auto frame_count =
|
||||
CaptureStackBackTrace(0, static_cast<DWORD>(std::size(frames)), frames, nullptr);
|
||||
const auto image_base = reinterpret_cast<uintptr_t>(GetModuleHandleW(nullptr));
|
||||
for (uint16_t i = 0; i < frame_count; i++) {
|
||||
const auto address = reinterpret_cast<uintptr_t>(frames[i]);
|
||||
@@ -580,9 +580,9 @@ bool PageManager::HandleFault(PageFaultAccess access, uint64_t fault_vaddr) noex
|
||||
FailFast("page remained inaccessible after waiting for its resolver");
|
||||
}
|
||||
// More than one CPU can fault before a protection transition becomes visible. The first
|
||||
// delayed fault consumes the hint bit; later faults must also resume once the mapped page
|
||||
// already permits the requested access. A genuinely read-only/no-access page still falls
|
||||
// through to the guest exception path.
|
||||
// delayed fault consumes the hint bit; later faults must also resume once the mapped
|
||||
// page already permits the requested access. A genuinely read-only/no-access page still
|
||||
// falls through to the guest exception path.
|
||||
return allowed;
|
||||
}
|
||||
if ((access != PageFaultAccess::Read && access != PageFaultAccess::Write) ||
|
||||
|
||||
@@ -683,8 +683,8 @@ std::pair<VulkanBuffer*, uint64_t> BufferCache::ObtainBuffer(CommandBuffer* com
|
||||
// host page protection is irrelevant.
|
||||
if (is_read && !is_written && size <= CACHING_PAGE_SIZE &&
|
||||
!m_memory_tracker.IsRegionGpuModified(vaddr, size) &&
|
||||
m_memory_tracker.IsRegionCpuModified(vaddr, size) &&
|
||||
!texture_region.gpu_image_bytes && !texture_region.gpu_metadata_bytes) {
|
||||
m_memory_tracker.IsRegionCpuModified(vaddr, size) && !texture_region.gpu_image_bytes &&
|
||||
!texture_region.gpu_metadata_bytes) {
|
||||
std::array<uint8_t, CACHING_PAGE_SIZE> guest_data;
|
||||
if (Libs::LibKernel::Memory::TryReadBacking(vaddr, guest_data.data(), size)) {
|
||||
VulkanBuffer* stream_buffer = nullptr;
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include "graphics/guest_gpu/tile.h"
|
||||
#include "graphics/host_gpu/graphicContext.h"
|
||||
#include "graphics/host_gpu/objects/textureCommon.h"
|
||||
#include "graphics/host_gpu/renderer/descriptorCache.h"
|
||||
#include "graphics/host_gpu/renderer/debug.h"
|
||||
#include "graphics/host_gpu/renderer/descriptorCache.h"
|
||||
#include "graphics/host_gpu/renderer/framebufferCache.h"
|
||||
#include "graphics/host_gpu/renderer/render.h"
|
||||
#include "graphics/host_gpu/renderer/renderContext.h"
|
||||
@@ -402,9 +402,8 @@ void ResolveRenderColorTarget(uint64_t submit_id, CommandBuffer* buffer, const H
|
||||
}
|
||||
if (standard64 &&
|
||||
(rt.attrib3.dimension != 1 || rt.attrib3.depth != 0 || levels != 1 ||
|
||||
rt.view.current_mip_level != 0 ||
|
||||
view.base_layer != 0 || view.image_layers != 1 || rt.attrib.num_samples != 0 ||
|
||||
rt.attrib.num_fragments != 0 || bytes_per_element != 4 ||
|
||||
rt.view.current_mip_level != 0 || view.base_layer != 0 || view.image_layers != 1 ||
|
||||
rt.attrib.num_samples != 0 || rt.attrib.num_fragments != 0 || bytes_per_element != 4 ||
|
||||
rt.pitch.pitch_div8_minus1 != 0 || (rt.base.addr & 0xffffu) != 0 ||
|
||||
rt.info.fmask_compression_enable || rt.info.fmask_data_compression_disable ||
|
||||
rt.info.fmask_one_frag_mode || rt.info.cmask_fast_clear_enable ||
|
||||
@@ -415,9 +414,8 @@ void ResolveRenderColorTarget(uint64_t submit_id, CommandBuffer* buffer, const H
|
||||
" dimension=%u depth=%u levels=%u layer=%u/%u samples=%u fragments=%u bpe=%u"
|
||||
" cmask=0x%016" PRIx64 " fmask=0x%016" PRIx64 " dcc=0x%016" PRIx64 "\n",
|
||||
rt.base.addr, rt.attrib3.dimension, rt.attrib3.depth, levels, view.base_layer,
|
||||
view.image_layers,
|
||||
rt.attrib.num_samples, rt.attrib.num_fragments, bytes_per_element, rt.cmask.addr,
|
||||
rt.fmask.addr, rt.dcc_addr.addr);
|
||||
view.image_layers, rt.attrib.num_samples, rt.attrib.num_fragments, bytes_per_element,
|
||||
rt.cmask.addr, rt.fmask.addr, rt.dcc_addr.addr);
|
||||
}
|
||||
if (rt.pitch.pitch_div8_minus1 != 0) {
|
||||
pitch = (rt.pitch.pitch_div8_minus1 + 1u) << 3u;
|
||||
@@ -438,7 +436,8 @@ void ResolveRenderColorTarget(uint64_t submit_id, CommandBuffer* buffer, const H
|
||||
bool valid_layout = false;
|
||||
if (standard64) {
|
||||
TileGetTextureSize(Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float), width,
|
||||
height, pitch, levels, rt.attrib3.tile_mode, &layout, nullptr, nullptr);
|
||||
height, pitch, levels, rt.attrib3.tile_mode, &layout, nullptr,
|
||||
nullptr);
|
||||
valid_layout = layout.size != 0 && layout.align == 65536;
|
||||
} else {
|
||||
valid_layout =
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#include "common/emulatorConfig.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/stringUtils.h"
|
||||
#include "graphics/guest_gpu/hardwareContext.h"
|
||||
#include "graphics/guest_gpu/gpu_defs.h"
|
||||
#include "graphics/guest_gpu/hardwareContext.h"
|
||||
#include "graphics/host_gpu/renderer/render.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
@@ -129,10 +129,9 @@ void ResolveRenderDepthTarget(uint64_t submit_id, CommandBuffer* buffer, const H
|
||||
// DB_DEPTH_SIZE_XY is independent state and may remain programmed after the attachment
|
||||
// formats and addresses are unbound. A zero encoding is the valid 1x1 value, so its
|
||||
// presence alone must not manufacture a depth attachment.
|
||||
!z.z_info.tile_surface_enable && !z.width_height_valid &&
|
||||
!z.pitch_height_valid && z.size.x_max == 0 && z.size.y_max == 0 &&
|
||||
z.pitch_div8_minus1 == 0 && z.height_div8_minus1 == 0 && z.slice_div64_minus1 == 0 &&
|
||||
z.width == 0 && z.height == 0;
|
||||
!z.z_info.tile_surface_enable && !z.width_height_valid && !z.pitch_height_valid &&
|
||||
z.size.x_max == 0 && z.size.y_max == 0 && z.pitch_div8_minus1 == 0 &&
|
||||
z.height_div8_minus1 == 0 && z.slice_div64_minus1 == 0 && z.width == 0 && z.height == 0;
|
||||
if (attachment_unbound) {
|
||||
static std::atomic_bool logged = false;
|
||||
if (!logged.exchange(true, std::memory_order_relaxed)) {
|
||||
|
||||
@@ -152,7 +152,7 @@ static BufferView NativeStorageBuffer(uint64_t submit_id, CommandBuffer* command
|
||||
const ShaderRecompiler::IR::BufferResource& resource) {
|
||||
BufferView result;
|
||||
|
||||
//Regression
|
||||
// Regression
|
||||
// Bind a null buffer when these four dwords are
|
||||
// the tracked prefix of an active image sharp. Image validity is encoded by dword 3 bit 31.
|
||||
/*if (resource.image_alias != ShaderRecompiler::IR::BufferResource::NoImageAlias &&
|
||||
@@ -299,9 +299,9 @@ static bool IsSupportedSampledColorResource(const ShaderRecompiler::IR::ImageRes
|
||||
!resource.written && !resource.atomic && !resource.depth_compare;
|
||||
}
|
||||
|
||||
TargetTextureViewInfo
|
||||
ResolveTargetTextureView(const ShaderRecompiler::IR::ImageResource& resource,
|
||||
Prospero::ImageType type, uint32_t base_layer, uint32_t image_layers) {
|
||||
TargetTextureViewInfo ResolveTargetTextureView(const ShaderRecompiler::IR::ImageResource& resource,
|
||||
Prospero::ImageType type, uint32_t base_layer,
|
||||
uint32_t image_layers) {
|
||||
switch (type) {
|
||||
case Prospero::ImageType::kColor2D:
|
||||
return resource.dimension == ShaderRecompiler::Decoder::ImageDimension::Dim2D &&
|
||||
@@ -338,16 +338,15 @@ bool IsSupportedDepthTargetDescriptor(const ShaderTextureResource& descriptor,
|
||||
const auto height = static_cast<uint32_t>(descriptor.Height5()) + 1u;
|
||||
const auto pitch = TileGetTexturePitch(descriptor.Format(), width, 1, descriptor.TileMode());
|
||||
const auto type = static_cast<Prospero::ImageType>(descriptor.Type());
|
||||
const bool supported_type = type == Prospero::ImageType::kColor2D ||
|
||||
type == Prospero::ImageType::kColor2DArray;
|
||||
const bool supported_type =
|
||||
type == Prospero::ImageType::kColor2D || type == Prospero::ImageType::kColor2DArray;
|
||||
return image.type == VulkanImageType::DepthStencil && image.layers == 1 &&
|
||||
width == image.extent.width && height == image.extent.height &&
|
||||
descriptor.Depth() == 0 && descriptor.BaseLevel() == 0 && descriptor.LastLevel() == 0 &&
|
||||
descriptor.MaxMip() == 0 && descriptor.MinLod() == 0 && descriptor.BaseArray5() == 0 &&
|
||||
descriptor.TileMode() == Prospero::GpuEnumValue(Prospero::TileMode::kDepth) &&
|
||||
supported_type &&
|
||||
descriptor.BCSwizzle() == 0 && !descriptor.MsaaDepth() && pitch >= width &&
|
||||
pitch == image.guest_pitch;
|
||||
supported_type && descriptor.BCSwizzle() == 0 && !descriptor.MsaaDepth() &&
|
||||
pitch >= width && pitch == image.guest_pitch;
|
||||
}
|
||||
|
||||
static bool IsSupportedDepthTextureEncoding(const ShaderTextureResource& descriptor) {
|
||||
@@ -359,9 +358,9 @@ static bool IsSupportedDepthTextureEncoding(const ShaderTextureResource& descrip
|
||||
(descriptor.Type() << 28u) | field3_common | descriptor.DstSelXYZW();
|
||||
return (descriptor.fields[1] & field1_reserved_mask) == 0 &&
|
||||
(descriptor.fields[2] & field2_reserved_mask) == 0 &&
|
||||
descriptor.fields[3] == field3_expected &&
|
||||
descriptor.fields[4] == 0 && descriptor.fields[5] == field5_expected &&
|
||||
descriptor.fields[6] == 0 && descriptor.fields[7] == 0;
|
||||
descriptor.fields[3] == field3_expected && descriptor.fields[4] == 0 &&
|
||||
descriptor.fields[5] == field5_expected && descriptor.fields[6] == 0 &&
|
||||
descriptor.fields[7] == 0;
|
||||
}
|
||||
|
||||
static void ValidateDepthTargetBinding(const ShaderRecompiler::IR::ImageResource& resource,
|
||||
@@ -567,8 +566,8 @@ NativeTexture(uint64_t submit_id, CommandBuffer* command_buffer,
|
||||
descriptor.MsaaDepth();
|
||||
if (image == nullptr) {
|
||||
if (check_depth) {
|
||||
image = g_render_ctx->GetTextureCache()->FindDepthTargetByRange(
|
||||
command_buffer, address, size.size, true);
|
||||
image = g_render_ctx->GetTextureCache()->FindDepthTargetByRange(command_buffer, address,
|
||||
size.size, true);
|
||||
} else {
|
||||
image = g_render_ctx->GetTextureCache()->FindRenderTargetByRange(command_buffer,
|
||||
address, size.size);
|
||||
@@ -594,7 +593,8 @@ NativeTexture(uint64_t submit_id, CommandBuffer* command_buffer,
|
||||
resource, type, descriptor.BaseArray5(), image->layers);
|
||||
ValidateDepthTargetBinding(resource, descriptor, image, view_format, size.size);
|
||||
if (depth_view.type == VK_IMAGE_VIEW_TYPE_MAX_ENUM) {
|
||||
EXIT("unsupported sampled depth target view: dimension=%u descriptor_type=%u "
|
||||
EXIT("unsupported sampled depth target view: dimension=%u "
|
||||
"descriptor_type=%u "
|
||||
"base_array=%u image_layers=%u\n",
|
||||
static_cast<uint32_t>(resource.dimension), descriptor.Type(),
|
||||
descriptor.BaseArray5(), image->layers);
|
||||
|
||||
@@ -19,8 +19,7 @@ struct TargetTextureViewInfo {
|
||||
|
||||
[[nodiscard]] TargetTextureViewInfo
|
||||
ResolveTargetTextureView(const ShaderRecompiler::IR::ImageResource& resource,
|
||||
Prospero::ImageType type, uint32_t base_layer,
|
||||
uint32_t image_layers);
|
||||
Prospero::ImageType type, uint32_t base_layer, uint32_t image_layers);
|
||||
|
||||
[[nodiscard]] bool IsSupportedDepthTargetDescriptor(const ShaderTextureResource& descriptor,
|
||||
const VulkanImage& image);
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Libs::Graphics {
|
||||
|
||||
class DummyTextureCache final {
|
||||
public:
|
||||
enum class Usage: uint8_t { Sampled, Storage };
|
||||
enum class Usage : uint8_t { Sampled, Storage };
|
||||
|
||||
DummyTextureCache() = default;
|
||||
~DummyTextureCache();
|
||||
|
||||
@@ -40,8 +40,7 @@ TextureImageCreateParams MakeImageParams(const ImageInfo& info, bool storage) {
|
||||
params.image_layout = TextureUploadDestination::MipLevels;
|
||||
params.allow_cube_view = !storage;
|
||||
params.compatible_format_views =
|
||||
storage &&
|
||||
(IsRgba8SrgbViewFormat(TextureGetFormat(info.format, params.format_usage)) ||
|
||||
storage && (IsRgba8SrgbViewFormat(TextureGetFormat(info.format, params.format_usage)) ||
|
||||
info.format == Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt) ||
|
||||
info.format == Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float));
|
||||
params.owner = storage ? "StorageTextureCache" : "TextureCache";
|
||||
@@ -60,7 +59,8 @@ bool RenderTargetSupportsStorage(GraphicContext* ctx, VkFormat format, VkImageCr
|
||||
|
||||
VkImageCreateFlags RenderTargetCreateFlags(VkFormat format) {
|
||||
const bool compatible_format_view =
|
||||
IsRgba8SrgbViewFormat(format) || BgraToRgbaSampledViewFormat(format) != VK_FORMAT_UNDEFINED ||
|
||||
IsRgba8SrgbViewFormat(format) ||
|
||||
BgraToRgbaSampledViewFormat(format) != VK_FORMAT_UNDEFINED ||
|
||||
format == VK_FORMAT_R8G8B8A8_UINT || format == VK_FORMAT_R16G16B16A16_SFLOAT ||
|
||||
format == VK_FORMAT_R16G16B16A16_UINT;
|
||||
return compatible_format_view
|
||||
@@ -107,8 +107,7 @@ static constexpr uint32_t DummyTextureSwizzle() {
|
||||
}
|
||||
|
||||
TextureImageCreateParams MakeDummyTextureParams(bool uint_format, bool image_3d,
|
||||
TextureFormatUsage usage,
|
||||
const char* owner) {
|
||||
TextureFormatUsage usage, const char* owner) {
|
||||
TextureImageCreateParams params {};
|
||||
params.fmt = static_cast<uint32_t>(
|
||||
Prospero::GpuEnumValue(uint_format ? Prospero::BufferFormat::k8_8_8_8UInt
|
||||
|
||||
@@ -100,8 +100,8 @@ private:
|
||||
|
||||
namespace ImageOps {
|
||||
|
||||
[[nodiscard]] GpuTextureVulkanImage*
|
||||
CreateTexture(GraphicContext* ctx, const ImageInfo& info, bool storage, VulkanMemory* memory,
|
||||
[[nodiscard]] GpuTextureVulkanImage* CreateTexture(GraphicContext* ctx, const ImageInfo& info,
|
||||
bool storage, VulkanMemory* memory,
|
||||
VkComponentMapping* components);
|
||||
void CreateTextureViews(GraphicContext* ctx, GpuTextureVulkanImage* image, const ImageInfo& info,
|
||||
bool storage, VkComponentMapping components);
|
||||
@@ -119,13 +119,13 @@ void UploadRenderTarget(GraphicContext* ctx, RenderTextureVulkanImage* image,
|
||||
CreateDepthTarget(GraphicContext* ctx, const DepthTargetInfo& info, VulkanMemory* memory);
|
||||
|
||||
void ValidateVideoOut(GraphicContext* ctx, const VideoOutInfo& info);
|
||||
[[nodiscard]] VideoOutVulkanImage*
|
||||
CreateVideoOut(GraphicContext* ctx, const VideoOutInfo& info, VulkanMemory* memory);
|
||||
[[nodiscard]] VideoOutVulkanImage* CreateVideoOut(GraphicContext* ctx, const VideoOutInfo& info,
|
||||
VulkanMemory* memory);
|
||||
void UploadVideoOut(GraphicContext* ctx, VideoOutVulkanImage* image, const VideoOutInfo& info,
|
||||
bool refresh);
|
||||
|
||||
[[nodiscard]] GpuTextureVulkanImage*
|
||||
CreateDummyTexture(GraphicContext* ctx, bool uint_format, bool image_3d, bool storage,
|
||||
[[nodiscard]] GpuTextureVulkanImage* CreateDummyTexture(GraphicContext* ctx, bool uint_format,
|
||||
bool image_3d, bool storage,
|
||||
VulkanMemory* memory);
|
||||
|
||||
void Destroy(GraphicContext* ctx, GpuTextureVulkanImage* image, VulkanMemory* memory);
|
||||
|
||||
@@ -225,12 +225,7 @@ FindGuestDepthFormatPolicy(uint32_t guest_format) noexcept {
|
||||
: info.format == policy->depth_attachment_format);
|
||||
}
|
||||
|
||||
enum class VideoOutCompression : uint8_t {
|
||||
Uncompressed,
|
||||
Dcc256_256_0,
|
||||
Dcc256_64_64,
|
||||
Unsupported
|
||||
};
|
||||
enum class VideoOutCompression : uint8_t { Uncompressed, Dcc256_256_0, Dcc256_64_64, Unsupported };
|
||||
|
||||
struct VideoOutInfo {
|
||||
uint64_t address = 0;
|
||||
@@ -388,8 +383,9 @@ enum class MetaImageOverlap : uint8_t { RetainSampled, RetireTarget, Unsupported
|
||||
return storage ? 0u : view_base_level;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline constexpr bool IsDepthUintTextureReinterpretation(
|
||||
VkFormat image_format, uint32_t guest_format, VkFormat view_format) noexcept {
|
||||
[[nodiscard]] inline constexpr bool
|
||||
IsDepthUintTextureReinterpretation(VkFormat image_format, uint32_t guest_format,
|
||||
VkFormat view_format) noexcept {
|
||||
switch (image_format) {
|
||||
case VK_FORMAT_D32_SFLOAT:
|
||||
return guest_format == Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt) &&
|
||||
@@ -429,8 +425,8 @@ SelectStorageSampledViewShape(uint32_t type, uint32_t depth, uint32_t backing_la
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] inline constexpr bool IsSupportedDisplayRenderTargetTileMode(
|
||||
uint32_t tile_mode) noexcept {
|
||||
[[nodiscard]] inline constexpr bool
|
||||
IsSupportedDisplayRenderTargetTileMode(uint32_t tile_mode) noexcept {
|
||||
return tile_mode == Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget);
|
||||
}
|
||||
|
||||
@@ -639,10 +635,8 @@ SelectDepthTransitionSource(bool depth_load_clear, bool sampled_native_available
|
||||
[[nodiscard]] inline bool IsRgba16UintFloatReinterpretation(VkFormat cached,
|
||||
VkFormat requested) noexcept {
|
||||
switch (cached) {
|
||||
case VK_FORMAT_R16G16B16A16_SFLOAT:
|
||||
return requested == VK_FORMAT_R16G16B16A16_UINT;
|
||||
case VK_FORMAT_R16G16B16A16_UINT:
|
||||
return requested == VK_FORMAT_R16G16B16A16_SFLOAT;
|
||||
case VK_FORMAT_R16G16B16A16_SFLOAT: return requested == VK_FORMAT_R16G16B16A16_UINT;
|
||||
case VK_FORMAT_R16G16B16A16_UINT: return requested == VK_FORMAT_R16G16B16A16_SFLOAT;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
@@ -664,14 +658,13 @@ SelectDepthTransitionSource(bool depth_load_clear, bool sampled_native_available
|
||||
sampled.size == target.size * sampled.depth && sampled.width == target.width &&
|
||||
sampled.height == target.height && sampled.pitch == target.pitch;
|
||||
return sampled.address == target.address && sampled.size > target.size &&
|
||||
sampled.format == target.guest_format &&
|
||||
target.format == VK_FORMAT_D32_SFLOAT &&
|
||||
sampled.format == target.guest_format && target.format == VK_FORMAT_D32_SFLOAT &&
|
||||
target.guest_format == Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float) &&
|
||||
target.bytes_per_element == 4 && target.stencil_address == 0 &&
|
||||
target.stencil_size == 0 && target.htile_address == 0 && target.htile_size == 0 &&
|
||||
target.layers == 1 && array_expansion &&
|
||||
sampled.base_level == 0 && sampled.levels == 1 && sampled.view_levels == 1 &&
|
||||
sampled.tile == target.tile_mode && sampled.base_array == 0;
|
||||
target.layers == 1 && array_expansion && sampled.base_level == 0 &&
|
||||
sampled.levels == 1 && sampled.view_levels == 1 && sampled.tile == target.tile_mode &&
|
||||
sampled.base_array == 0;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline StorageSampledOverlap
|
||||
@@ -834,10 +827,10 @@ ClassifyStorageBufferRebind(bool buffer_overlap, bool cached_gpu_modified,
|
||||
// does not require the otherwise necessary image content copy.
|
||||
[[nodiscard]] inline DepthOverlap ClassifyStorageDepthOverlap(const ImageInfo& storage,
|
||||
const DepthTargetInfo& depth) {
|
||||
const bool overlaps_depth = ImageRangeOverlaps(storage.address, storage.size, depth.address,
|
||||
depth.size);
|
||||
const bool overlaps_stencil = depth.stencil_address != 0 &&
|
||||
ImageRangeOverlaps(storage.address, storage.size,
|
||||
const bool overlaps_depth =
|
||||
ImageRangeOverlaps(storage.address, storage.size, depth.address, depth.size);
|
||||
const bool overlaps_stencil =
|
||||
depth.stencil_address != 0 && ImageRangeOverlaps(storage.address, storage.size,
|
||||
depth.stencil_address, depth.stencil_size);
|
||||
if (!overlaps_depth && !overlaps_stencil) {
|
||||
return DepthOverlap::None;
|
||||
|
||||
@@ -125,11 +125,11 @@ VkImageView TextureCache::GetRenderTargetAttachmentView(GraphicContext*
|
||||
static_cast<int>(image->format), static_cast<int>(format), level);
|
||||
}
|
||||
|
||||
return GetImageView(
|
||||
ctx, image,
|
||||
{format, layer_count == 1 ? VK_IMAGE_VIEW_TYPE_2D : VK_IMAGE_VIEW_TYPE_2D_ARRAY,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT, level, 1, base_layer, layer_count, DstSel(4, 5, 6, 7),
|
||||
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT});
|
||||
return GetImageView(ctx, image,
|
||||
{format,
|
||||
layer_count == 1 ? VK_IMAGE_VIEW_TYPE_2D : VK_IMAGE_VIEW_TYPE_2D_ARRAY,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT, level, 1, base_layer, layer_count,
|
||||
DstSel(4, 5, 6, 7), VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT});
|
||||
}
|
||||
|
||||
VkImageView TextureCache::GetDepthTargetAttachmentView(GraphicContext* ctx,
|
||||
@@ -309,8 +309,7 @@ VkImageView TextureCache::GetRenderTargetStorageView(GraphicContext* c
|
||||
}
|
||||
return GetImageView(ctx, image,
|
||||
{view_format, type, VK_IMAGE_ASPECT_COLOR_BIT, base_level, level_count,
|
||||
base_layer, layer_count, DstSel(4, 5, 6, 7),
|
||||
VK_IMAGE_USAGE_STORAGE_BIT});
|
||||
base_layer, layer_count, DstSel(4, 5, 6, 7), VK_IMAGE_USAGE_STORAGE_BIT});
|
||||
}
|
||||
|
||||
VkImageView TextureCache::GetStorageTextureSampledView(GraphicContext* ctx,
|
||||
@@ -362,8 +361,7 @@ VkImageView TextureCache::GetStorageTextureStorageView(GraphicContext*
|
||||
}
|
||||
return GetImageView(ctx, image,
|
||||
{image->format, VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
base_level, 1, 0, 1, DstSel(4, 5, 6, 7),
|
||||
VK_IMAGE_USAGE_STORAGE_BIT});
|
||||
base_level, 1, 0, 1, DstSel(4, 5, 6, 7), VK_IMAGE_USAGE_STORAGE_BIT});
|
||||
}
|
||||
|
||||
} // namespace Libs::Graphics
|
||||
|
||||
@@ -18,8 +18,7 @@ namespace Libs::Graphics {
|
||||
format == Prospero::GpuEnumValue(Prospero::BufferFormat::k16Float) ||
|
||||
format == Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float);
|
||||
return swizzle == DstSel(4, 5, 6, 7) ||
|
||||
(single_channel && (swizzle == DstSel(4, 0, 0, 0) ||
|
||||
swizzle == DstSel(4, 0, 0, 1) ||
|
||||
(single_channel && (swizzle == DstSel(4, 0, 0, 0) || swizzle == DstSel(4, 0, 0, 1) ||
|
||||
swizzle == DstSel(4, 4, 4, 4))) ||
|
||||
(format == Prospero::GpuEnumValue(Prospero::BufferFormat::k32_32UInt) &&
|
||||
swizzle == DstSel(4, 5, 0, 1)) ||
|
||||
@@ -104,8 +103,7 @@ namespace Libs::Graphics {
|
||||
return true;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline bool IsSupportedSampledColorView(VkFormat image_format,
|
||||
VkFormat view_format,
|
||||
[[nodiscard]] inline bool IsSupportedSampledColorView(VkFormat image_format, VkFormat view_format,
|
||||
uint32_t swizzle) noexcept {
|
||||
if (!IsValidSampledColorSwizzle(swizzle)) {
|
||||
return false;
|
||||
@@ -118,8 +116,7 @@ namespace Libs::Graphics {
|
||||
swizzle == DstSel(4, 5, 6, 7)) {
|
||||
return true;
|
||||
}
|
||||
return IsBgraToRgbaSampledView(image_format, view_format) &&
|
||||
swizzle == DstSel(6, 5, 4, 7);
|
||||
return IsBgraToRgbaSampledView(image_format, view_format) && swizzle == DstSel(6, 5, 4, 7);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline uint32_t SelectSampledColorView(VkFormat image_format, VkFormat view_format,
|
||||
@@ -177,8 +174,7 @@ IsSupportedSampledDepthUintResource(const ShaderRecompiler::IR::ImageResource& r
|
||||
view_format == VK_FORMAT_R16_SFLOAT || view_format == VK_FORMAT_R32_SFLOAT;
|
||||
const bool swizzle_ok =
|
||||
swizzle == DstSel(4, 5, 6, 7) ||
|
||||
(single_channel && (swizzle == DstSel(4, 0, 0, 0) ||
|
||||
swizzle == DstSel(4, 0, 0, 1) ||
|
||||
(single_channel && (swizzle == DstSel(4, 0, 0, 0) || swizzle == DstSel(4, 0, 0, 1) ||
|
||||
swizzle == DstSel(4, 4, 4, 4))) ||
|
||||
(view_format == VK_FORMAT_R32G32_UINT && swizzle == DstSel(4, 5, 0, 1)) ||
|
||||
((view_format == VK_FORMAT_R8G8B8A8_UNORM || view_format == VK_FORMAT_R8G8B8A8_UINT) &&
|
||||
|
||||
@@ -15,7 +15,8 @@ namespace Libs::Graphics {
|
||||
|
||||
// Sparse two-level lookup for texture-cache page ownership.
|
||||
// Entries are selected by guest page number; queries never allocate L1 buckets.
|
||||
template <typename EntryT, size_t PageBits = 20, size_t AddressSpaceBits = 40, size_t FirstLevelBits = 10>
|
||||
template <typename EntryT, size_t PageBits = 20, size_t AddressSpaceBits = 40,
|
||||
size_t FirstLevelBits = 10>
|
||||
class MultiLevelPageTable final {
|
||||
public:
|
||||
using Entry = EntryT;
|
||||
@@ -28,10 +29,10 @@ public:
|
||||
static constexpr size_t kAddressSpaceBits = AddressSpaceBits;
|
||||
static constexpr size_t kFirstLevelBits = FirstLevelBits;
|
||||
static constexpr size_t kSecondLevelBits = AddressSpaceBits - FirstLevelBits - PageBits;
|
||||
static constexpr size_t kFirstLevelEntries = size_t{1} << FirstLevelBits;
|
||||
static constexpr size_t kBucketEntries = size_t{1} << kSecondLevelBits;
|
||||
static constexpr size_t kPageCount = size_t{1} << (AddressSpaceBits - PageBits);
|
||||
static constexpr uint64_t kAddressSpaceSize = uint64_t{1} << AddressSpaceBits;
|
||||
static constexpr size_t kFirstLevelEntries = size_t {1} << FirstLevelBits;
|
||||
static constexpr size_t kBucketEntries = size_t {1} << kSecondLevelBits;
|
||||
static constexpr size_t kPageCount = size_t {1} << (AddressSpaceBits - PageBits);
|
||||
static constexpr uint64_t kAddressSpaceSize = uint64_t {1} << AddressSpaceBits;
|
||||
|
||||
struct PageRange final {
|
||||
size_t first = 0;
|
||||
@@ -74,7 +75,8 @@ public:
|
||||
|
||||
// Returns the half-open page interval touched by a non-empty byte range.
|
||||
// An end exactly at 2^AddressSpaceBits is valid; wrapping or crossing it is not.
|
||||
[[nodiscard]] static constexpr bool TryGetPageRange(uint64_t address, uint64_t size, PageRange& range) {
|
||||
[[nodiscard]] static constexpr bool TryGetPageRange(uint64_t address, uint64_t size,
|
||||
PageRange& range) {
|
||||
if (size == 0 || address >= kAddressSpaceSize || size > kAddressSpaceSize - address) {
|
||||
return false;
|
||||
}
|
||||
@@ -89,8 +91,12 @@ public:
|
||||
private:
|
||||
using Bucket = std::array<Entry, kBucketEntries>;
|
||||
|
||||
[[nodiscard]] static constexpr size_t FirstLevelIndex(size_t page) { return page >> kSecondLevelBits; }
|
||||
[[nodiscard]] static constexpr size_t SecondLevelIndex(size_t page) { return page & (kBucketEntries - 1); }
|
||||
[[nodiscard]] static constexpr size_t FirstLevelIndex(size_t page) {
|
||||
return page >> kSecondLevelBits;
|
||||
}
|
||||
[[nodiscard]] static constexpr size_t SecondLevelIndex(size_t page) {
|
||||
return page & (kBucketEntries - 1);
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<Bucket>> m_first_level;
|
||||
size_t m_allocated_buckets = 0;
|
||||
@@ -179,7 +185,8 @@ public:
|
||||
}
|
||||
|
||||
template <typename Predicate>
|
||||
[[nodiscard]] std::vector<OwnerT> Query(uint64_t address, uint64_t size, Predicate&& predicate) const {
|
||||
[[nodiscard]] std::vector<OwnerT> Query(uint64_t address, uint64_t size,
|
||||
Predicate&& predicate) const {
|
||||
return QueryImpl(address, size, true, std::forward<Predicate>(predicate));
|
||||
}
|
||||
|
||||
@@ -190,7 +197,8 @@ public:
|
||||
}
|
||||
|
||||
template <typename Predicate>
|
||||
[[nodiscard]] std::vector<OwnerT> QueryCandidates(uint64_t address, uint64_t size, Predicate&& predicate) const {
|
||||
[[nodiscard]] std::vector<OwnerT> QueryCandidates(uint64_t address, uint64_t size,
|
||||
Predicate&& predicate) const {
|
||||
return QueryImpl(address, size, false, std::forward<Predicate>(predicate));
|
||||
}
|
||||
|
||||
@@ -207,8 +215,8 @@ private:
|
||||
template <typename Predicate>
|
||||
[[nodiscard]] std::vector<OwnerT> QueryImpl(uint64_t address, uint64_t size, bool strict_bytes,
|
||||
Predicate&& predicate) const {
|
||||
typename CoarseTable::PageRange coarse_range{};
|
||||
typename TrackingTable::PageRange tracking_range{};
|
||||
typename CoarseTable::PageRange coarse_range {};
|
||||
typename TrackingTable::PageRange tracking_range {};
|
||||
if (!CoarseTable::TryGetPageRange(address, size, coarse_range) ||
|
||||
!TrackingTable::TryGetPageRange(address, size, tracking_range)) {
|
||||
return {};
|
||||
@@ -222,7 +230,8 @@ private:
|
||||
std::vector<OwnerT> result;
|
||||
for (const Registration* registration: candidates) {
|
||||
if ((!strict_bytes || Overlaps(registration->ranges, address, size)) &&
|
||||
HasTrackingMembership(registration, tracking_range) && predicate(registration->owner)) {
|
||||
HasTrackingMembership(registration, tracking_range) &&
|
||||
predicate(registration->owner)) {
|
||||
result.push_back(registration->owner);
|
||||
}
|
||||
}
|
||||
@@ -248,20 +257,22 @@ private:
|
||||
[[nodiscard]] static std::vector<ByteRange> Normalize(const std::vector<ByteRange>& ranges) {
|
||||
std::vector<ByteRange> sorted;
|
||||
for (const auto& range: ranges) {
|
||||
typename CoarseTable::PageRange ignored{};
|
||||
typename CoarseTable::PageRange ignored {};
|
||||
if (!CoarseTable::TryGetPageRange(range.address, range.size, ignored)) {
|
||||
return {};
|
||||
}
|
||||
sorted.push_back(range);
|
||||
}
|
||||
std::sort(sorted.begin(), sorted.end(),
|
||||
[](const ByteRange& lhs, const ByteRange& rhs) { return lhs.address < rhs.address; });
|
||||
std::sort(sorted.begin(), sorted.end(), [](const ByteRange& lhs, const ByteRange& rhs) {
|
||||
return lhs.address < rhs.address;
|
||||
});
|
||||
std::vector<ByteRange> merged;
|
||||
for (const auto& range: sorted) {
|
||||
if (merged.empty() || range.address > merged.back().address + merged.back().size) {
|
||||
merged.push_back(range);
|
||||
} else {
|
||||
const uint64_t end = std::max(merged.back().address + merged.back().size, range.address + range.size);
|
||||
const uint64_t end = std::max(merged.back().address + merged.back().size,
|
||||
range.address + range.size);
|
||||
merged.back().size = end - merged.back().address;
|
||||
}
|
||||
}
|
||||
@@ -284,11 +295,13 @@ private:
|
||||
}
|
||||
|
||||
template <typename Table>
|
||||
[[nodiscard]] static bool HasAllMemberships(const Table& table, const std::vector<size_t>& pages,
|
||||
[[nodiscard]] static bool HasAllMemberships(const Table& table,
|
||||
const std::vector<size_t>& pages,
|
||||
const Registration* registration) {
|
||||
for (const size_t page: pages) {
|
||||
const auto* owners = table.Find(page);
|
||||
if (owners == nullptr || std::find(owners->begin(), owners->end(), registration) == owners->end()) {
|
||||
if (owners == nullptr ||
|
||||
std::find(owners->begin(), owners->end(), registration) == owners->end()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -299,14 +312,16 @@ private:
|
||||
const typename TrackingTable::PageRange& range) const {
|
||||
for (size_t page = range.first; page < range.last_exclusive; ++page) {
|
||||
const auto* owners = m_tracking_pages.Find(page);
|
||||
if (owners != nullptr && std::find(owners->begin(), owners->end(), registration) != owners->end()) {
|
||||
if (owners != nullptr &&
|
||||
std::find(owners->begin(), owners->end(), registration) != owners->end()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
[[nodiscard]] static bool Overlaps(const std::vector<ByteRange>& ranges, uint64_t address, uint64_t size) {
|
||||
[[nodiscard]] static bool Overlaps(const std::vector<ByteRange>& ranges, uint64_t address,
|
||||
uint64_t size) {
|
||||
const uint64_t end = address + size;
|
||||
return std::any_of(ranges.begin(), ranges.end(), [&](const ByteRange& range) {
|
||||
return range.address < end && address < range.address + range.size;
|
||||
@@ -314,19 +329,21 @@ private:
|
||||
}
|
||||
static void AppendUnique(MembershipList& destination, const MembershipList& source) {
|
||||
for (const Registration* registration: source) {
|
||||
if (std::find(destination.begin(), destination.end(), registration) == destination.end()) {
|
||||
if (std::find(destination.begin(), destination.end(), registration) ==
|
||||
destination.end()) {
|
||||
destination.push_back(registration);
|
||||
}
|
||||
}
|
||||
}
|
||||
[[nodiscard]] static std::vector<ByteRange> CoalesceTrackingPages(const std::vector<size_t>& pages) {
|
||||
[[nodiscard]] static std::vector<ByteRange>
|
||||
CoalesceTrackingPages(const std::vector<size_t>& pages) {
|
||||
std::vector<ByteRange> result;
|
||||
for (const size_t page: pages) {
|
||||
const uint64_t address = static_cast<uint64_t>(page) << 12;
|
||||
if (!result.empty() && result.back().address + result.back().size == address) {
|
||||
result.back().size += uint64_t{1} << 12;
|
||||
result.back().size += uint64_t {1} << 12;
|
||||
} else {
|
||||
result.push_back({address, uint64_t{1} << 12});
|
||||
result.push_back({address, uint64_t {1} << 12});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "graphics/host_gpu/renderer/renderDraw.h"
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/common.h"
|
||||
#include "common/emulatorConfig.h"
|
||||
@@ -20,7 +22,6 @@
|
||||
#include "graphics/host_gpu/renderer/pipelineCache.h"
|
||||
#include "graphics/host_gpu/renderer/render.h"
|
||||
#include "graphics/host_gpu/renderer/renderContext.h"
|
||||
#include "graphics/host_gpu/renderer/renderDraw.h"
|
||||
#include "graphics/host_gpu/renderer/renderInternal.h"
|
||||
#include "graphics/host_gpu/renderer/renderVertex.h"
|
||||
#include "graphics/host_gpu/renderer/shaderResourceBarrier.h"
|
||||
@@ -823,8 +824,8 @@ static void BindDrawIndexBuffer(CommandBuffer* buffer, VkCommandBuffer vk_buffer
|
||||
VkDeviceSize index_offset = 0;
|
||||
if (source.host_data != nullptr) {
|
||||
VkDeviceSize range = 0;
|
||||
if (!g_render_ctx->GetBufferCache()->UploadHostData(
|
||||
buffer, g_render_ctx->GetGraphicCtx(), source.host_data, source.size, 16,
|
||||
if (!g_render_ctx->GetBufferCache()->UploadHostData(buffer, g_render_ctx->GetGraphicCtx(),
|
||||
source.host_data, source.size, 16,
|
||||
&index_buffer, &index_offset, &range)) {
|
||||
EXIT("failed to upload host index buffer\n");
|
||||
}
|
||||
@@ -1144,9 +1145,8 @@ void RenderDrawIndex(uint64_t submit_id, CommandBuffer* buffer, HW::Context* ctx
|
||||
index_source.address = reinterpret_cast<uint64_t>(index_addr);
|
||||
index_source.host_data =
|
||||
expanded_indices.empty() ? nullptr : static_cast<const void*>(expanded_indices.data());
|
||||
index_source.size = expanded_indices.empty()
|
||||
? index_size
|
||||
: expanded_indices.size() * sizeof(uint16_t);
|
||||
index_source.size =
|
||||
expanded_indices.empty() ? index_size : expanded_indices.size() * sizeof(uint16_t);
|
||||
index_source.type = index_type;
|
||||
|
||||
DrawRenderState state {};
|
||||
|
||||
@@ -217,8 +217,7 @@ void GraphicsRenderDepthStencilBarrier(CommandBuffer* buffer, uint64_t vaddr, ui
|
||||
Common::LockGuard lock(g_render_ctx->GetMutex());
|
||||
|
||||
auto* vk_buffer = buffer->GetPool()->buffers[buffer->GetIndex()];
|
||||
auto* native =
|
||||
g_render_ctx->GetTextureCache()->FindDepthTargetByRange(buffer, vaddr, size);
|
||||
auto* native = g_render_ctx->GetTextureCache()->FindDepthTargetByRange(buffer, vaddr, size);
|
||||
if (native == nullptr) {
|
||||
EXIT("depth-target barrier range has no cached image\n");
|
||||
}
|
||||
|
||||
@@ -66,15 +66,18 @@ VkSampler SamplerCache::GetSampler(const ShaderSamplerResource& r) {
|
||||
auto to_vk_address_mode = [](uint8_t clamp) {
|
||||
switch (static_cast<Prospero::SamplerClampMode>(clamp)) {
|
||||
case Prospero::SamplerClampMode::kWrap: return VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||
case Prospero::SamplerClampMode::kMirror: return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT;
|
||||
case Prospero::SamplerClampMode::kClampLastTexel: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
||||
case Prospero::SamplerClampMode::kMirror:
|
||||
return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT;
|
||||
case Prospero::SamplerClampMode::kClampLastTexel:
|
||||
return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
|
||||
case Prospero::SamplerClampMode::kMirrorOnceLastTexel:
|
||||
return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE;
|
||||
case Prospero::SamplerClampMode::kClampHalfBorder:
|
||||
return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;
|
||||
case Prospero::SamplerClampMode::kMirrorOnceHalfBorder:
|
||||
return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE;
|
||||
case Prospero::SamplerClampMode::kClampBorder: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;
|
||||
case Prospero::SamplerClampMode::kClampBorder:
|
||||
return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER;
|
||||
case Prospero::SamplerClampMode::kMirrorOnceBorder:
|
||||
return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE;
|
||||
default: EXIT("unknown clamp: %u\n", clamp);
|
||||
@@ -87,8 +90,12 @@ VkSampler SamplerCache::GetSampler(const ShaderSamplerResource& r) {
|
||||
case Prospero::SamplerBorderColor::kTransBlack:
|
||||
border = VK_BORDER_COLOR_INT_TRANSPARENT_BLACK;
|
||||
break;
|
||||
case Prospero::SamplerBorderColor::kOpaqueBlack: border = VK_BORDER_COLOR_INT_OPAQUE_BLACK; break;
|
||||
case Prospero::SamplerBorderColor::kOpaqueWhite: border = VK_BORDER_COLOR_INT_OPAQUE_WHITE; break;
|
||||
case Prospero::SamplerBorderColor::kOpaqueBlack:
|
||||
border = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
|
||||
break;
|
||||
case Prospero::SamplerBorderColor::kOpaqueWhite:
|
||||
border = VK_BORDER_COLOR_INT_OPAQUE_WHITE;
|
||||
break;
|
||||
case Prospero::SamplerBorderColor::kFromTable:
|
||||
LOGF(
|
||||
"temporary: approximating table border color as transparent black, index = %" PRIu16
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "graphics/host_gpu/renderer/descriptorCache.h"
|
||||
#include "graphics/shader/shaderBindings.h"
|
||||
#include "graphics/shader/shader.h"
|
||||
#include "graphics/shader/shaderBindings.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
namespace Libs::Graphics {
|
||||
|
||||
//IDK: maybe we can remove it?
|
||||
// IDK: maybe we can remove it?
|
||||
constexpr uint32_t kTemporaryPs5BufferFormat121 = 121u;
|
||||
|
||||
static bool NarrowInputFormat(VkFormat* format, uint32_t* size, uint32_t used_components) {
|
||||
|
||||
@@ -41,13 +41,11 @@ void HostStreamBuffer::EnsureBuffer(GraphicContext* ctx) {
|
||||
VulkanCreateBuffer(ctx, CAPACITY, m_buffer.get());
|
||||
VulkanMapMemory(ctx, &m_buffer->memory, &m_mapped);
|
||||
const auto count = g_stream_buffer_count.fetch_add(1, std::memory_order_relaxed) + 1;
|
||||
LOGF("HostStreamBuffer: created serial=%" PRIu64 " capacity=%" PRIu64 "\n", count,
|
||||
CAPACITY);
|
||||
LOGF("HostStreamBuffer: created serial=%" PRIu64 " capacity=%" PRIu64 "\n", count, CAPACITY);
|
||||
}
|
||||
|
||||
bool HostStreamBuffer::Copy(GraphicContext* ctx, const void* src, uint64_t size,
|
||||
uint64_t alignment, VulkanBuffer** out_buffer, uint64_t* out_offset,
|
||||
uint64_t* out_range) {
|
||||
bool HostStreamBuffer::Copy(GraphicContext* ctx, const void* src, uint64_t size, uint64_t alignment,
|
||||
VulkanBuffer** out_buffer, uint64_t* out_offset, uint64_t* out_range) {
|
||||
KYTY_PROFILER_FUNCTION();
|
||||
if (ctx == nullptr || src == nullptr || out_buffer == nullptr || out_offset == nullptr ||
|
||||
out_range == nullptr) {
|
||||
|
||||
@@ -22,9 +22,8 @@ public:
|
||||
~HostStreamBuffer();
|
||||
KYTY_CLASS_NO_COPY(HostStreamBuffer);
|
||||
|
||||
[[nodiscard]] bool Copy(GraphicContext* ctx, const void* src, uint64_t size,
|
||||
uint64_t alignment, VulkanBuffer** out_buffer, uint64_t* out_offset,
|
||||
uint64_t* out_range);
|
||||
[[nodiscard]] bool Copy(GraphicContext* ctx, const void* src, uint64_t size, uint64_t alignment,
|
||||
VulkanBuffer** out_buffer, uint64_t* out_offset, uint64_t* out_range);
|
||||
void Reset() noexcept;
|
||||
void Release() noexcept;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "graphics/host_gpu/renderer/sync.h"
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/common.h"
|
||||
#include "common/logging/log.h"
|
||||
@@ -7,7 +9,6 @@
|
||||
#include "graphics/host_gpu/renderer/bufferCache.h"
|
||||
#include "graphics/host_gpu/renderer/render.h"
|
||||
#include "graphics/host_gpu/renderer/renderContext.h"
|
||||
#include "graphics/host_gpu/renderer/sync.h"
|
||||
#include "graphics/presentation/displayBuffer.h"
|
||||
#include "kernel/eventQueue.h"
|
||||
#include "kernel/pthread.h"
|
||||
@@ -82,8 +83,8 @@ void TriggerEopEvent(uint32_t context_id) {
|
||||
g_render_ctx->TriggerEopEvent(context_id);
|
||||
}
|
||||
|
||||
void WriteAtEndOfPipe32(uint64_t submit_id, CommandBuffer* buffer,
|
||||
uint32_t* dst_gpu_addr, uint32_t value) {
|
||||
void WriteAtEndOfPipe32(uint64_t submit_id, CommandBuffer* buffer, uint32_t* dst_gpu_addr,
|
||||
uint32_t value) {
|
||||
EXIT_IF(g_render_ctx == nullptr);
|
||||
EXIT_IF(dst_gpu_addr == nullptr);
|
||||
EXIT_IF(buffer == nullptr);
|
||||
@@ -93,9 +94,8 @@ void WriteAtEndOfPipe32(uint64_t submit_id, CommandBuffer* buffer,
|
||||
0, 0, reinterpret_cast<uint64_t>(dst_gpu_addr));
|
||||
}
|
||||
|
||||
void WriteAtEndOfPipeGds32(uint64_t submit_id, CommandBuffer* buffer,
|
||||
uint32_t* dst_gpu_addr, uint32_t dw_offset,
|
||||
uint32_t dw_num) {
|
||||
void WriteAtEndOfPipeGds32(uint64_t submit_id, CommandBuffer* buffer, uint32_t* dst_gpu_addr,
|
||||
uint32_t dw_offset, uint32_t dw_num) {
|
||||
EXIT_IF(g_render_ctx == nullptr);
|
||||
EXIT_IF(dst_gpu_addr == nullptr);
|
||||
EXIT_IF(buffer == nullptr);
|
||||
@@ -105,8 +105,8 @@ void WriteAtEndOfPipeGds32(uint64_t submit_id, CommandBuffer* buffer,
|
||||
dw_offset, dw_num, 0, 0, reinterpret_cast<uint64_t>(dst_gpu_addr));
|
||||
}
|
||||
|
||||
void WriteAtEndOfPipe64(uint64_t submit_id, CommandBuffer* buffer,
|
||||
uint64_t* dst_gpu_addr, uint64_t value) {
|
||||
void WriteAtEndOfPipe64(uint64_t submit_id, CommandBuffer* buffer, uint64_t* dst_gpu_addr,
|
||||
uint64_t value) {
|
||||
EXIT_IF(g_render_ctx == nullptr);
|
||||
EXIT_IF(dst_gpu_addr == nullptr);
|
||||
EXIT_IF(buffer == nullptr);
|
||||
@@ -117,8 +117,8 @@ void WriteAtEndOfPipe64(uint64_t submit_id, CommandBuffer* buffer,
|
||||
reinterpret_cast<uint64_t>(dst_gpu_addr));
|
||||
}
|
||||
|
||||
void WriteAtEndOfPipeClockCounter(uint64_t submit_id, CommandBuffer* buffer,
|
||||
uint64_t* dst_gpu_addr, uint64_t value) {
|
||||
void WriteAtEndOfPipeClockCounter(uint64_t submit_id, CommandBuffer* buffer, uint64_t* dst_gpu_addr,
|
||||
uint64_t value) {
|
||||
EXIT_IF(g_render_ctx == nullptr);
|
||||
EXIT_IF(dst_gpu_addr == nullptr);
|
||||
EXIT_IF(buffer == nullptr);
|
||||
@@ -132,10 +132,8 @@ void WriteAtEndOfPipeClockCounter(uint64_t submit_id, CommandBuffer* buffer,
|
||||
reinterpret_cast<uint64_t>(dst_gpu_addr), value);
|
||||
}
|
||||
|
||||
void WriteAtEndOfPipeClockCounterWithWriteBack(uint64_t submit_id,
|
||||
CommandBuffer* buffer,
|
||||
uint64_t* dst_gpu_addr,
|
||||
uint64_t value) {
|
||||
void WriteAtEndOfPipeClockCounterWithWriteBack(uint64_t submit_id, CommandBuffer* buffer,
|
||||
uint64_t* dst_gpu_addr, uint64_t value) {
|
||||
EXIT_IF(g_render_ctx == nullptr);
|
||||
EXIT_IF(dst_gpu_addr == nullptr);
|
||||
EXIT_IF(buffer == nullptr);
|
||||
@@ -172,8 +170,7 @@ void WriteAtEndOfPipeWithWriteBack32(uint64_t submit_id, CommandBuffer* buffer,
|
||||
value, 0, 0, reinterpret_cast<uint64_t>(dst_gpu_addr));
|
||||
}
|
||||
|
||||
void WriteAtEndOfPipeWithInterruptWriteBack64(uint64_t submit_id,
|
||||
CommandBuffer* buffer,
|
||||
void WriteAtEndOfPipeWithInterruptWriteBack64(uint64_t submit_id, CommandBuffer* buffer,
|
||||
uint64_t* dst_gpu_addr, uint64_t value,
|
||||
uint32_t context_id) {
|
||||
EXIT_IF(g_render_ctx == nullptr);
|
||||
@@ -197,8 +194,7 @@ void WriteAtEndOfPipeWithInterruptWriteBack64(uint64_t submit_id,
|
||||
args);
|
||||
}
|
||||
|
||||
void WriteAtEndOfPipeWithInterruptWriteBack32(uint64_t submit_id,
|
||||
CommandBuffer* buffer,
|
||||
void WriteAtEndOfPipeWithInterruptWriteBack32(uint64_t submit_id, CommandBuffer* buffer,
|
||||
uint32_t* dst_gpu_addr, uint32_t value,
|
||||
uint32_t context_id) {
|
||||
EXIT_IF(g_render_ctx == nullptr);
|
||||
@@ -221,8 +217,7 @@ void WriteAtEndOfPipeWithInterruptWriteBack32(uint64_t submit_id,
|
||||
}
|
||||
|
||||
void WriteAtEndOfPipeWithInterrupt64(uint64_t submit_id, CommandBuffer* buffer,
|
||||
uint64_t* dst_gpu_addr, uint64_t value,
|
||||
uint32_t context_id) {
|
||||
uint64_t* dst_gpu_addr, uint64_t value, uint32_t context_id) {
|
||||
EXIT_IF(g_render_ctx == nullptr);
|
||||
EXIT_IF(dst_gpu_addr == nullptr);
|
||||
EXIT_IF(buffer == nullptr);
|
||||
@@ -245,8 +240,7 @@ void WriteAtEndOfPipeWithInterrupt64(uint64_t submit_id, CommandBuffer* buffer,
|
||||
}
|
||||
|
||||
void WriteAtEndOfPipeWithInterrupt32(uint64_t submit_id, CommandBuffer* buffer,
|
||||
uint32_t* dst_gpu_addr, uint32_t value,
|
||||
uint32_t context_id) {
|
||||
uint32_t* dst_gpu_addr, uint32_t value, uint32_t context_id) {
|
||||
EXIT_IF(g_render_ctx == nullptr);
|
||||
EXIT_IF(dst_gpu_addr == nullptr);
|
||||
EXIT_IF(buffer == nullptr);
|
||||
@@ -266,8 +260,8 @@ void WriteAtEndOfPipeWithInterrupt32(uint64_t submit_id, CommandBuffer* buffer,
|
||||
args);
|
||||
}
|
||||
|
||||
uint64_t PrepareDisplayBufferFlip(CommandBuffer* buffer, int handle, int index,
|
||||
int flip_mode, int64_t flip_arg) {
|
||||
uint64_t PrepareDisplayBufferFlip(CommandBuffer* buffer, int handle, int index, int flip_mode,
|
||||
int64_t flip_arg) {
|
||||
for (;;) {
|
||||
uint64_t request_id = 0;
|
||||
const auto result = Presentation::DisplayBufferSubmitFlipFromGpu(
|
||||
@@ -285,9 +279,10 @@ uint64_t PrepareDisplayBufferFlip(CommandBuffer* buffer, int handle, int index,
|
||||
}
|
||||
}
|
||||
|
||||
void WriteAtEndOfPipeWithInterruptWriteBackFlip32(
|
||||
uint64_t submit_id, CommandBuffer* buffer, uint32_t* dst_gpu_addr, uint32_t value, int handle,
|
||||
int index, int flip_mode, int64_t flip_arg, uint64_t request_id) {
|
||||
void WriteAtEndOfPipeWithInterruptWriteBackFlip32(uint64_t submit_id, CommandBuffer* buffer,
|
||||
uint32_t* dst_gpu_addr, uint32_t value,
|
||||
int handle, int index, int flip_mode,
|
||||
int64_t flip_arg, uint64_t request_id) {
|
||||
EXIT_IF(g_render_ctx == nullptr);
|
||||
EXIT_IF(dst_gpu_addr == nullptr);
|
||||
EXIT_IF(buffer == nullptr);
|
||||
@@ -307,10 +302,9 @@ void WriteAtEndOfPipeWithInterruptWriteBackFlip32(
|
||||
args);
|
||||
}
|
||||
|
||||
void WriteAtEndOfPipeWithFlip32(uint64_t submit_id, CommandBuffer* buffer,
|
||||
uint32_t* dst_gpu_addr, uint32_t value, int handle,
|
||||
int index, int flip_mode, int64_t flip_arg,
|
||||
uint64_t request_id) {
|
||||
void WriteAtEndOfPipeWithFlip32(uint64_t submit_id, CommandBuffer* buffer, uint32_t* dst_gpu_addr,
|
||||
uint32_t value, int handle, int index, int flip_mode,
|
||||
int64_t flip_arg, uint64_t request_id) {
|
||||
EXIT_IF(g_render_ctx == nullptr);
|
||||
EXIT_IF(dst_gpu_addr == nullptr);
|
||||
EXIT_IF(buffer == nullptr);
|
||||
@@ -323,9 +317,8 @@ void WriteAtEndOfPipeWithFlip32(uint64_t submit_id, CommandBuffer* buffer,
|
||||
SubmitLabel(buffer, CompleteDisplayBufferFlip, nullptr, args);
|
||||
}
|
||||
|
||||
void WriteAtEndOfPipeOnlyFlip(uint64_t submit_id, CommandBuffer* buffer, int handle,
|
||||
int index, int flip_mode, int64_t flip_arg,
|
||||
uint64_t request_id) {
|
||||
void WriteAtEndOfPipeOnlyFlip(uint64_t submit_id, CommandBuffer* buffer, int handle, int index,
|
||||
int flip_mode, int64_t flip_arg, uint64_t request_id) {
|
||||
EXIT_IF(g_render_ctx == nullptr);
|
||||
EXIT_IF(buffer == nullptr);
|
||||
EXIT_IF(buffer->IsInvalid());
|
||||
|
||||
@@ -25,8 +25,8 @@ void WriteAtEndOfPipe64(uint64_t submit_id, CommandBuffer* buffer, uint64_t* dst
|
||||
uint64_t value);
|
||||
void WriteAtEndOfPipeGds32(uint64_t submit_id, CommandBuffer* buffer, uint32_t* dst_gpu_addr,
|
||||
uint32_t dw_offset, uint32_t dw_num);
|
||||
void WriteAtEndOfPipeClockCounter(uint64_t submit_id, CommandBuffer* buffer,
|
||||
uint64_t* dst_gpu_addr, uint64_t value);
|
||||
void WriteAtEndOfPipeClockCounter(uint64_t submit_id, CommandBuffer* buffer, uint64_t* dst_gpu_addr,
|
||||
uint64_t value);
|
||||
void WriteAtEndOfPipeClockCounterWithWriteBack(uint64_t submit_id, CommandBuffer* buffer,
|
||||
uint64_t* dst_gpu_addr, uint64_t value);
|
||||
void WriteAtEndOfPipeWithWriteBack32(uint64_t submit_id, CommandBuffer* buffer,
|
||||
@@ -50,9 +50,9 @@ void WriteAtEndOfPipeWithInterruptWriteBack64(uint64_t submit_id, CommandBuffer*
|
||||
int flip_mode, int64_t flip_arg);
|
||||
void WriteAtEndOfPipeOnlyFlip(uint64_t submit_id, CommandBuffer* buffer, int handle, int index,
|
||||
int flip_mode, int64_t flip_arg, uint64_t request_id);
|
||||
void WriteAtEndOfPipeWithFlip32(uint64_t submit_id, CommandBuffer* buffer,
|
||||
uint32_t* dst_gpu_addr, uint32_t value, int handle, int index,
|
||||
int flip_mode, int64_t flip_arg, uint64_t request_id);
|
||||
void WriteAtEndOfPipeWithFlip32(uint64_t submit_id, CommandBuffer* buffer, uint32_t* dst_gpu_addr,
|
||||
uint32_t value, int handle, int index, int flip_mode,
|
||||
int64_t flip_arg, uint64_t request_id);
|
||||
void WriteAtEndOfPipeWithInterruptWriteBackFlip32(uint64_t submit_id, CommandBuffer* buffer,
|
||||
uint32_t* dst_gpu_addr, uint32_t value,
|
||||
int handle, int index, int flip_mode,
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
#include "graphics/host_gpu/utils.h"
|
||||
#include "kernel/memory.h"
|
||||
|
||||
#include <xxhash.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <cstdlib>
|
||||
@@ -30,6 +28,7 @@
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <thread>
|
||||
#include <xxhash.h>
|
||||
|
||||
namespace Libs::Graphics {
|
||||
|
||||
@@ -246,7 +245,8 @@ void TextureCache::UnregisterImageLocked(CachedImage& image, bool release_tracki
|
||||
VulkanImage* TextureCache::PublishImage(CommandBuffer* command,
|
||||
std::shared_ptr<CachedImage> image) {
|
||||
if (command == nullptr || image == nullptr || image->image == nullptr || image->registered) {
|
||||
EXIT("TextureCache: invalid image publication, command=%p record=%p image=%p registered=%d\n",
|
||||
EXIT("TextureCache: invalid image publication, command=%p record=%p image=%p "
|
||||
"registered=%d\n",
|
||||
static_cast<const void*>(command), static_cast<const void*>(image.get()),
|
||||
image != nullptr ? static_cast<const void*>(image->image) : nullptr,
|
||||
image != nullptr && image->registered);
|
||||
@@ -423,8 +423,7 @@ struct TextureCache::ReadbackWorker {
|
||||
(!has_htile || (expected_htile.size <= UINT64_MAX / info.layers &&
|
||||
info.htile_size == expected_htile.size * info.layers));
|
||||
if ((require_fault_range && !fault_in_depth) || has_stencil || info.address == 0 ||
|
||||
info.size == 0 ||
|
||||
info.width == 0 || info.height == 0 || info.pitch < info.width ||
|
||||
info.size == 0 || info.width == 0 || info.height == 0 || info.pitch < info.width ||
|
||||
info.tile_mode != Prospero::GpuEnumValue(Prospero::TileMode::kDepth) ||
|
||||
!prospero_layout || info.pitch != expected_pitch || !layered_sizes ||
|
||||
expected_depth.align != 65536u || cached.image->layers != info.layers ||
|
||||
@@ -862,8 +861,7 @@ TextureCache::CachedImage* TextureCache::FindGpuReadbackPageCandidateLocked(uint
|
||||
if (selected != nullptr) {
|
||||
EXIT("TextureCache: CPU fault has multiple GPU-modified image page candidates, "
|
||||
"addr=0x%016" PRIx64 " size=0x%016" PRIx64 " first=%p second=%p\n",
|
||||
vaddr, size, static_cast<const void*>(selected),
|
||||
static_cast<const void*>(cached));
|
||||
vaddr, size, static_cast<const void*>(selected), static_cast<const void*>(cached));
|
||||
}
|
||||
selected = cached;
|
||||
}
|
||||
@@ -929,8 +927,8 @@ void TextureCache::RetireSampledTargetAliases(GraphicContext* ctx, const ImageIn
|
||||
const bool contained =
|
||||
delta <= requested.size && cached->depth.size <= requested.size - delta;
|
||||
const bool sampled_expansion = IsSampledDepthExpansion(requested, cached->depth);
|
||||
const bool exact_range = requested.address == cached->depth.address &&
|
||||
requested.size == cached->depth.size;
|
||||
const bool exact_range =
|
||||
requested.address == cached->depth.address && requested.size == cached->depth.size;
|
||||
const bool supported = cached->ctx == ctx && !cached->buffer_modified &&
|
||||
cached->depth.stencil_address == 0 &&
|
||||
cached->depth.stencil_size == 0 && cached->depth.layers == 1 &&
|
||||
@@ -1049,8 +1047,7 @@ void TextureCache::ResolveStorageImageOverlaps(GraphicContext* ctx, const ImageI
|
||||
RetireImages(retire);
|
||||
}
|
||||
|
||||
void TextureCache::RetireStorageDepthAliasLocked(GraphicContext* ctx,
|
||||
const ImageInfo& requested) {
|
||||
void TextureCache::RetireStorageDepthAliasLocked(GraphicContext* ctx, const ImageInfo& requested) {
|
||||
CachedImage* selected = nullptr;
|
||||
for (auto* entry: FindImagesInRegionLocked(requested.address, requested.size, true)) {
|
||||
auto& cached = *entry;
|
||||
@@ -1105,10 +1102,9 @@ TextureCache::~TextureCache() {
|
||||
|
||||
VulkanImage* TextureCache::FindTexture(CommandBuffer* command, GraphicContext* ctx,
|
||||
const ImageInfo& info, bool metadata_read) {
|
||||
if (info.address == 0 || info.size == 0 ||
|
||||
info.address >= TRACKER_ADDRESS_SIZE || info.size > TRACKER_ADDRESS_SIZE - info.address ||
|
||||
info.width == 0 || info.height == 0 || info.depth == 0 || info.levels == 0 ||
|
||||
info.levels >= 16 || info.view_levels == 0 ||
|
||||
if (info.address == 0 || info.size == 0 || info.address >= TRACKER_ADDRESS_SIZE ||
|
||||
info.size > TRACKER_ADDRESS_SIZE - info.address || info.width == 0 || info.height == 0 ||
|
||||
info.depth == 0 || info.levels == 0 || info.levels >= 16 || info.view_levels == 0 ||
|
||||
info.base_level + info.view_levels > info.levels) {
|
||||
EXIT("TextureCache: invalid sampled-image request, command=%p ctx=%p addr=0x%016" PRIx64
|
||||
" size=0x%016" PRIx64 " extent=%ux%ux%u levels=%u\n",
|
||||
@@ -1292,11 +1288,10 @@ StorageTextureVulkanImage* TextureCache::FindStorageTexture(CommandBuffer* com
|
||||
const bool supported_depth_tile =
|
||||
info.tile == Prospero::GpuEnumValue(Prospero::TileMode::kDepth) &&
|
||||
IsSupportedStorageDepthTile(info.format, info.type, info.width, info.height, info.depth);
|
||||
if (info.address == 0 || info.size == 0 ||
|
||||
info.address >= TRACKER_ADDRESS_SIZE || info.size > TRACKER_ADDRESS_SIZE - info.address ||
|
||||
info.width == 0 || info.height == 0 || info.depth == 0 || info.levels == 0 ||
|
||||
info.levels > 16 || info.base_level >= info.levels || info.view_levels != 1 ||
|
||||
info.base_array != 0 || !supported_type ||
|
||||
if (info.address == 0 || info.size == 0 || info.address >= TRACKER_ADDRESS_SIZE ||
|
||||
info.size > TRACKER_ADDRESS_SIZE - info.address || info.width == 0 || info.height == 0 ||
|
||||
info.depth == 0 || info.levels == 0 || info.levels > 16 || info.base_level >= info.levels ||
|
||||
info.view_levels != 1 || info.base_array != 0 || !supported_type ||
|
||||
(info.tile != Prospero::GpuEnumValue(Prospero::TileMode::kLinear) &&
|
||||
info.tile != Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget) &&
|
||||
!supported_depth_tile) ||
|
||||
@@ -1373,9 +1368,9 @@ StorageTextureVulkanImage* TextureCache::FindStorageTexture(CommandBuffer* com
|
||||
m_memory_tracker.ForEachUploadRange(
|
||||
info.address, info.size, true, [](uint64_t, uint64_t) noexcept {},
|
||||
[&]() noexcept {
|
||||
m_tiler.DetileImage(
|
||||
match->ctx, static_cast<GpuTextureVulkanImage*>(match->image), match->info,
|
||||
source, true, true);
|
||||
m_tiler.DetileImage(match->ctx,
|
||||
static_cast<GpuTextureVulkanImage*>(match->image),
|
||||
match->info, source, true, true);
|
||||
});
|
||||
match->buffer_modified = false;
|
||||
match->gpu_modified = true;
|
||||
@@ -1415,8 +1410,8 @@ StorageTextureVulkanImage* TextureCache::FindStorageTexture(CommandBuffer* com
|
||||
cached->info, source, false, true);
|
||||
});
|
||||
cached->gpu_modified = true;
|
||||
ImageOps::CreateTextureViews(ctx, static_cast<GpuTextureVulkanImage*>(cached->image), info, true,
|
||||
components);
|
||||
ImageOps::CreateTextureViews(ctx, static_cast<GpuTextureVulkanImage*>(cached->image), info,
|
||||
true, components);
|
||||
return static_cast<StorageTextureVulkanImage*>(PublishImage(command, std::move(cached)));
|
||||
}
|
||||
|
||||
@@ -1424,11 +1419,11 @@ RenderTextureVulkanImage* TextureCache::FindRenderTarget(CommandBuffer*
|
||||
GraphicContext* ctx,
|
||||
const RenderTargetInfo& info) {
|
||||
const bool standard64 = IsSupportedStandard64RenderTarget(info);
|
||||
if (info.address == 0 || info.size == 0 ||
|
||||
info.address >= TRACKER_ADDRESS_SIZE || info.size > TRACKER_ADDRESS_SIZE - info.address ||
|
||||
info.format == VK_FORMAT_UNDEFINED || info.width == 0 || info.height == 0 ||
|
||||
info.pitch < info.width || info.bytes_per_element == 0 || info.levels == 0 ||
|
||||
info.levels > 16 || info.layers == 0 || info.size % info.layers != 0 ||
|
||||
if (info.address == 0 || info.size == 0 || info.address >= TRACKER_ADDRESS_SIZE ||
|
||||
info.size > TRACKER_ADDRESS_SIZE - info.address || info.format == VK_FORMAT_UNDEFINED ||
|
||||
info.width == 0 || info.height == 0 || info.pitch < info.width ||
|
||||
info.bytes_per_element == 0 || info.levels == 0 || info.levels > 16 || info.layers == 0 ||
|
||||
info.size % info.layers != 0 ||
|
||||
(info.tile_mode != Prospero::GpuEnumValue(Prospero::TileMode::kLinear) &&
|
||||
info.tile_mode != Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget) &&
|
||||
!standard64)) {
|
||||
@@ -1579,7 +1574,8 @@ RenderTextureVulkanImage* TextureCache::FindRenderTarget(CommandBuffer*
|
||||
}
|
||||
break;
|
||||
case RenderTargetOverlap::RetireTarget:
|
||||
supported = cached.kind == CachedImage::Kind::RenderTarget ||
|
||||
supported =
|
||||
cached.kind == CachedImage::Kind::RenderTarget ||
|
||||
(cached.kind == CachedImage::Kind::DepthTarget && target_buffer_overlap &&
|
||||
IsCoherentGuestImageSource(target_source, info.address, info.size));
|
||||
if (supported && cached.kind == CachedImage::Kind::DepthTarget) {
|
||||
@@ -1632,8 +1628,8 @@ RenderTextureVulkanImage* TextureCache::FindRenderTarget(CommandBuffer*
|
||||
tail_address, tail_size, true, [](uint64_t, uint64_t) noexcept {},
|
||||
[&]() noexcept {
|
||||
ImageOps::UploadRenderTargetLayers(
|
||||
ctx, static_cast<RenderTextureVulkanImage*>(cached->image), info, old.layers,
|
||||
info.layers - old.layers, false);
|
||||
ctx, static_cast<RenderTextureVulkanImage*>(cached->image), info,
|
||||
old.layers, info.layers - old.layers, false);
|
||||
});
|
||||
}
|
||||
std::vector<ImageImageCopy> regions;
|
||||
@@ -1658,11 +1654,10 @@ DepthStencilVulkanImage* TextureCache::FindDepthTarget(CommandBuffer* command, G
|
||||
const DepthTargetInfo& info) {
|
||||
const bool has_stencil = info.stencil_address != 0 || info.stencil_size != 0;
|
||||
const bool has_htile = info.htile_address != 0 || info.htile_size != 0;
|
||||
if (info.address == 0 || info.size == 0 ||
|
||||
info.address >= TRACKER_ADDRESS_SIZE || info.size > TRACKER_ADDRESS_SIZE - info.address ||
|
||||
(info.address & 0xffffu) != 0 || info.width == 0 || info.height == 0 ||
|
||||
info.pitch < info.width || info.layers == 0 || info.size % info.layers != 0 ||
|
||||
info.size > UINT32_MAX || info.stencil_size > UINT32_MAX ||
|
||||
if (info.address == 0 || info.size == 0 || info.address >= TRACKER_ADDRESS_SIZE ||
|
||||
info.size > TRACKER_ADDRESS_SIZE - info.address || (info.address & 0xffffu) != 0 ||
|
||||
info.width == 0 || info.height == 0 || info.pitch < info.width || info.layers == 0 ||
|
||||
info.size % info.layers != 0 || info.size > UINT32_MAX || info.stencil_size > UINT32_MAX ||
|
||||
info.tile_mode != Prospero::GpuEnumValue(Prospero::TileMode::kDepth) ||
|
||||
(has_stencil &&
|
||||
(info.stencil_address == 0 || info.stencil_size == 0 ||
|
||||
@@ -1760,9 +1755,8 @@ DepthStencilVulkanImage* TextureCache::FindDepthTarget(CommandBuffer* command, G
|
||||
m_memory_tracker.ForEachUploadRange(
|
||||
info.address, info.size, true, [](uint64_t, uint64_t) noexcept {},
|
||||
[&]() noexcept {
|
||||
m_tiler.DetileImage(ctx,
|
||||
static_cast<DepthStencilVulkanImage*>(match->image), info,
|
||||
depth_source, true);
|
||||
m_tiler.DetileImage(ctx, static_cast<DepthStencilVulkanImage*>(match->image),
|
||||
info, depth_source, true);
|
||||
});
|
||||
match->buffer_modified = false;
|
||||
match->gpu_modified = true;
|
||||
@@ -1832,17 +1826,15 @@ DepthStencilVulkanImage* TextureCache::FindDepthTarget(CommandBuffer* command, G
|
||||
case DepthOverlap::RetireStorage:
|
||||
supported = cached.kind == CachedImage::Kind::StorageTexture &&
|
||||
cached.gpu_modified && !cached.buffer_modified &&
|
||||
!cached.info.IsCpuDirty() &&
|
||||
retired_storage_source == nullptr && native_depth_source == nullptr &&
|
||||
discarded_depth_source == nullptr;
|
||||
!cached.info.IsCpuDirty() && retired_storage_source == nullptr &&
|
||||
native_depth_source == nullptr && discarded_depth_source == nullptr;
|
||||
if (supported) {
|
||||
retired_storage_source = entry;
|
||||
}
|
||||
break;
|
||||
case DepthOverlap::ExpandTarget:
|
||||
supported =
|
||||
cached.kind == CachedImage::Kind::DepthTarget && native_depth_source == nullptr &&
|
||||
retired_storage_source == nullptr;
|
||||
supported = cached.kind == CachedImage::Kind::DepthTarget &&
|
||||
native_depth_source == nullptr && retired_storage_source == nullptr;
|
||||
if (supported) {
|
||||
native_depth_source = entry;
|
||||
}
|
||||
@@ -1872,11 +1864,10 @@ DepthStencilVulkanImage* TextureCache::FindDepthTarget(CommandBuffer* command, G
|
||||
retired_storage_source->info.size);
|
||||
retired_storage_source->gpu_modified = false;
|
||||
}
|
||||
const auto* transition_source = native_depth_source != nullptr
|
||||
const auto* transition_source =
|
||||
native_depth_source != nullptr
|
||||
? native_depth_source.get()
|
||||
: (discarded_depth_source != nullptr
|
||||
? discarded_depth_source.get()
|
||||
: nullptr);
|
||||
: (discarded_depth_source != nullptr ? discarded_depth_source.get() : nullptr);
|
||||
RetireImages(retire, transition_source);
|
||||
const bool coherent_guest_stencil =
|
||||
has_stencil &&
|
||||
@@ -2050,8 +2041,8 @@ TextureCache::RegisterVideoOutSurfaces(GraphicContext* ctx,
|
||||
m_memory_tracker.ForEachUploadRange(
|
||||
info.address, info.size, false, [](uint64_t, uint64_t) noexcept {},
|
||||
[&]() noexcept {
|
||||
ImageOps::UploadVideoOut(
|
||||
ctx, static_cast<VideoOutVulkanImage*>(cached->image), info, false);
|
||||
ImageOps::UploadVideoOut(ctx, static_cast<VideoOutVulkanImage*>(cached->image),
|
||||
info, false);
|
||||
});
|
||||
} else {
|
||||
// A compressed guest surface cannot be decoded without its DCC metadata. Establish the
|
||||
@@ -2238,8 +2229,7 @@ bool TextureCache::ClearImageFromBuffer(CommandBuffer* command, uint64_t vaddr,
|
||||
return false;
|
||||
}
|
||||
uint8_t stencil_clear = 0;
|
||||
if (aspect == ClearAspect::Stencil &&
|
||||
!DecodePackedStencilClear(packed_clear, &stencil_clear)) {
|
||||
if (aspect == ClearAspect::Stencil && !DecodePackedStencilClear(packed_clear, &stencil_clear)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2257,8 +2247,7 @@ bool TextureCache::ClearImageFromBuffer(CommandBuffer* command, uint64_t vaddr,
|
||||
!buffer_overlap || IsCoherentGuestImageSource(source, vaddr, size);
|
||||
const bool image_cpu_modified = m_memory_tracker.IsRegionCpuModified(vaddr, size);
|
||||
const bool invalid_common = !buffer_source_valid || buffer_cpu_modified ||
|
||||
buffer_gpu_modified || match->buffer_modified ||
|
||||
image_cpu_modified;
|
||||
buffer_gpu_modified || match->buffer_modified || image_cpu_modified;
|
||||
if (aspect == ClearAspect::Color && invalid_common) {
|
||||
EXIT("TextureCache: compute image clear requires exclusive GPU image ownership, "
|
||||
"addr=0x%016" PRIx64 " size=0x%016" PRIx64
|
||||
@@ -2276,8 +2265,8 @@ bool TextureCache::ClearImageFromBuffer(CommandBuffer* command, uint64_t vaddr,
|
||||
" gpu_modified=%d buffer_overlap=%d source_valid=%d buffer_cpu_modified=%d"
|
||||
" buffer_gpu_modified=%d buffer_modified=%d image_cpu_modified=%d\n",
|
||||
plane, source_name, vaddr, size, match->gpu_modified, buffer_overlap,
|
||||
buffer_source_valid, buffer_cpu_modified, buffer_gpu_modified,
|
||||
match->buffer_modified, image_cpu_modified);
|
||||
buffer_source_valid, buffer_cpu_modified, buffer_gpu_modified, match->buffer_modified,
|
||||
image_cpu_modified);
|
||||
}
|
||||
|
||||
auto* vk_buffer = command->GetPool()->buffers[command->GetIndex()];
|
||||
@@ -2288,9 +2277,8 @@ bool TextureCache::ClearImageFromBuffer(CommandBuffer* command, uint64_t vaddr,
|
||||
}
|
||||
GraphicsRenderColorImageBarrier(vk_buffer, match->image,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
const VkImageSubresourceRange range {VK_IMAGE_ASPECT_COLOR_BIT, 0,
|
||||
VK_REMAINING_MIP_LEVELS, 0,
|
||||
match->image->layers};
|
||||
const VkImageSubresourceRange range {VK_IMAGE_ASPECT_COLOR_BIT, 0, VK_REMAINING_MIP_LEVELS,
|
||||
0, match->image->layers};
|
||||
vkCmdClearColorImage(vk_buffer, match->image->image, match->image->layout, &clear, 1,
|
||||
&range);
|
||||
GraphicsRenderColorImageBarrier(vk_buffer, match->image, RENDER_COLOR_IMAGE_LAYOUT);
|
||||
@@ -2441,8 +2429,7 @@ void TextureCache::PrepareHostWrite(uint64_t vaddr, uint64_t size) {
|
||||
MarkSampledAliasesCpuDirtyLocked(vaddr, size);
|
||||
}
|
||||
|
||||
void TextureCache::SynchronizeColorImageToBufferLocked(CachedImage& cached,
|
||||
uint64_t write_address,
|
||||
void TextureCache::SynchronizeColorImageToBufferLocked(CachedImage& cached, uint64_t write_address,
|
||||
uint64_t write_size) {
|
||||
const bool render_target = cached.kind == CachedImage::Kind::RenderTarget;
|
||||
const bool video_out = cached.kind == CachedImage::Kind::VideoOut;
|
||||
@@ -2485,18 +2472,17 @@ void TextureCache::SynchronizeColorImageToBufferLocked(CachedImage& cached,
|
||||
const bool layered_size =
|
||||
single_slice && static_cast<uint64_t>(exact.size) * target.layers == target.size;
|
||||
if (storage && target.levels > 1) {
|
||||
single_slice = TileGetRenderTargetMipLayout(
|
||||
target.width, target.height, target.pitch, target.bytes_per_element, target.levels,
|
||||
&exact, nullptr, nullptr);
|
||||
single_slice = TileGetRenderTargetMipLayout(target.width, target.height, target.pitch,
|
||||
target.bytes_per_element, target.levels, &exact,
|
||||
nullptr, nullptr);
|
||||
}
|
||||
const bool exact_tiled =
|
||||
tiled && exact.align == 65536 &&
|
||||
const bool exact_tiled = tiled && exact.align == 65536 &&
|
||||
(storage ? single_slice && exact.size == target.size : layered_size);
|
||||
const bool valid_kind = render_target || storage || (video_out && cached.video_out.compression ==
|
||||
VideoOutCompression::Uncompressed);
|
||||
const bool valid_kind =
|
||||
render_target || storage ||
|
||||
(video_out && cached.video_out.compression == VideoOutCompression::Uncompressed);
|
||||
if (!valid_kind || !cached.gpu_modified || cached.buffer_modified ||
|
||||
(!storage && target.levels != 1) ||
|
||||
target.size > UINT32_MAX || (!linear && !exact_tiled) ||
|
||||
(!storage && target.levels != 1) || target.size > UINT32_MAX || (!linear && !exact_tiled) ||
|
||||
HasMetaOverlapLocked(target.address, target.size)) {
|
||||
EXIT("TextureCache: unsupported color-image buffer synchronization, "
|
||||
"addr=0x%016" PRIx64 " size=0x%016" PRIx64
|
||||
@@ -2512,8 +2498,7 @@ void TextureCache::SynchronizeColorImageToBufferLocked(CachedImage& cached,
|
||||
write_address - target.address > target.size ||
|
||||
write_size > target.size - (write_address - target.address)) {
|
||||
EXIT("TextureCache: image synchronization write is outside backing, "
|
||||
"write=0x%016" PRIx64 "+0x%016" PRIx64 " image=0x%016" PRIx64
|
||||
"+0x%016" PRIx64 "\n",
|
||||
"write=0x%016" PRIx64 "+0x%016" PRIx64 " image=0x%016" PRIx64 "+0x%016" PRIx64 "\n",
|
||||
write_address, write_size, target.address, target.size);
|
||||
}
|
||||
const auto slice_size = target.size / target.layers;
|
||||
@@ -2580,8 +2565,7 @@ void TextureCache::SynchronizeColorImageToBufferLocked(CachedImage& cached,
|
||||
cached.buffer_modified = true;
|
||||
}
|
||||
|
||||
void TextureCache::SynchronizeDepthImageToBufferLocked(CachedImage& cached,
|
||||
uint64_t write_address,
|
||||
void TextureCache::SynchronizeDepthImageToBufferLocked(CachedImage& cached, uint64_t write_address,
|
||||
uint64_t write_size) {
|
||||
const auto& info = cached.depth;
|
||||
const bool has_stencil = info.stencil_address != 0 || info.stencil_size != 0;
|
||||
@@ -2589,30 +2573,32 @@ void TextureCache::SynchronizeDepthImageToBufferLocked(CachedImage& cached,
|
||||
TileSizeAlign expected_stencil {};
|
||||
TileSizeAlign expected_htile {};
|
||||
TileSizeAlign expected_depth {};
|
||||
const bool d16 = info.guest_format == Prospero::GpuEnumValue(Prospero::BufferFormat::k16UNorm) &&
|
||||
const bool d16 =
|
||||
info.guest_format == Prospero::GpuEnumValue(Prospero::BufferFormat::k16UNorm) &&
|
||||
info.format == VK_FORMAT_D16_UNORM && info.bytes_per_element == 2;
|
||||
const bool d32 = info.guest_format == Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float) &&
|
||||
const bool d32 =
|
||||
info.guest_format == Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float) &&
|
||||
info.format == VK_FORMAT_D32_SFLOAT && info.bytes_per_element == 4;
|
||||
const bool layout = (d16 || d32) &&
|
||||
const bool layout =
|
||||
(d16 || d32) &&
|
||||
TileGetDepthSize(info.width, info.height, 0,
|
||||
Prospero::GpuEnumValue(d16 ? Prospero::DepthFormat::kZ16
|
||||
: Prospero::DepthFormat::kZ32F),
|
||||
Prospero::GpuEnumValue(Prospero::StencilFormat::kInvalid),
|
||||
false, &expected_stencil, &expected_htile,
|
||||
&expected_depth);
|
||||
Prospero::GpuEnumValue(Prospero::StencilFormat::kInvalid), false,
|
||||
&expected_stencil, &expected_htile, &expected_depth);
|
||||
if (cached.kind != CachedImage::Kind::DepthTarget || !cached.gpu_modified ||
|
||||
cached.buffer_modified || write_address != info.address || write_size != info.size ||
|
||||
has_stencil || has_htile || info.layers != 1 || !layout ||
|
||||
expected_depth.align != 65536 || expected_depth.size != info.size ||
|
||||
cached.image->format != info.format || cached.image->extent.width != info.width ||
|
||||
cached.image->extent.height != info.height || HasMetaOverlapLocked(info.address, info.size)) {
|
||||
has_stencil || has_htile || info.layers != 1 || !layout || expected_depth.align != 65536 ||
|
||||
expected_depth.size != info.size || cached.image->format != info.format ||
|
||||
cached.image->extent.width != info.width || cached.image->extent.height != info.height ||
|
||||
HasMetaOverlapLocked(info.address, info.size)) {
|
||||
EXIT("TextureCache: unsupported depth-image buffer synchronization, "
|
||||
"write=0x%016" PRIx64 "+0x%016" PRIx64 " depth=0x%016" PRIx64
|
||||
"+0x%016" PRIx64 " extent=%ux%u layers=%u format=%d guest=%u bpe=%u"
|
||||
"write=0x%016" PRIx64 "+0x%016" PRIx64 " depth=0x%016" PRIx64 "+0x%016" PRIx64
|
||||
" extent=%ux%u layers=%u format=%d guest=%u bpe=%u"
|
||||
" stencil=%d htile=%d gpu_modified=%d buffer_modified=%d\n",
|
||||
write_address, write_size, info.address, info.size, info.width, info.height, info.layers,
|
||||
static_cast<int>(info.format), info.guest_format, info.bytes_per_element, has_stencil,
|
||||
has_htile, cached.gpu_modified, cached.buffer_modified);
|
||||
write_address, write_size, info.address, info.size, info.width, info.height,
|
||||
info.layers, static_cast<int>(info.format), info.guest_format, info.bytes_per_element,
|
||||
has_stencil, has_htile, cached.gpu_modified, cached.buffer_modified);
|
||||
}
|
||||
VulkanDeviceWaitIdle(cached.ctx);
|
||||
m_buffer_transition_linear.resize(info.size);
|
||||
@@ -2623,7 +2609,8 @@ void TextureCache::SynchronizeDepthImageToBufferLocked(CachedImage& cached,
|
||||
cached.image->layout);
|
||||
m_buffer_transition_guest.resize(info.size);
|
||||
m_tiler.TileImage(m_buffer_transition_guest.data(), m_buffer_transition_linear.data(), info);
|
||||
Libs::LibKernel::Memory::WriteBacking(info.address, m_buffer_transition_guest.data(), info.size);
|
||||
Libs::LibKernel::Memory::WriteBacking(info.address, m_buffer_transition_guest.data(),
|
||||
info.size);
|
||||
m_memory_tracker.ForEachDownloadRange<true>(info.address, info.size,
|
||||
[](uint64_t, uint64_t) noexcept {});
|
||||
m_buffer_cache.PublishImageBacking(write_address, write_size);
|
||||
@@ -2687,9 +2674,7 @@ bool TextureCache::InvalidateMemoryFromGPU(uint64_t vaddr, uint64_t size,
|
||||
case BufferImageWrite::InvalidateVideoOut:
|
||||
case BufferImageWrite::InvalidateStorageTexture:
|
||||
case BufferImageWrite::InvalidateDepthTarget:
|
||||
case BufferImageWrite::InvalidateRenderTarget:
|
||||
cached.buffer_modified = true;
|
||||
return true;
|
||||
case BufferImageWrite::InvalidateRenderTarget: cached.buffer_modified = true; return true;
|
||||
case BufferImageWrite::SynchronizeRenderTarget:
|
||||
case BufferImageWrite::SynchronizeStorageTexture:
|
||||
SynchronizeColorImageToBufferLocked(cached, vaddr, size);
|
||||
@@ -2724,9 +2709,8 @@ DepthStencilVulkanImage* TextureCache::FindDepthTargetByRange(CommandBuffer* com
|
||||
!cached->OverlapsRange(vaddr, size, false)) {
|
||||
continue;
|
||||
}
|
||||
const bool containing_sampled = allow_containing_sampled &&
|
||||
vaddr == cached->depth.address &&
|
||||
size > cached->depth.size;
|
||||
const bool containing_sampled =
|
||||
allow_containing_sampled && vaddr == cached->depth.address && size > cached->depth.size;
|
||||
if ((!IsDepthTargetRangeCompatible(cached->depth, vaddr, size) && !containing_sampled) ||
|
||||
found != nullptr) {
|
||||
EXIT("TextureCache: incompatible or ambiguous depth-target range, addr=0x%016" PRIx64
|
||||
@@ -2784,8 +2768,7 @@ RenderTextureVulkanImage* TextureCache::FindRenderTargetByRange(CommandBuffer* c
|
||||
if (found != nullptr) {
|
||||
EXIT("TextureCache: incompatible or ambiguous render-target range, addr=0x%016" PRIx64
|
||||
" size=0x%016" PRIx64 " cached=0x%016" PRIx64 "+0x%016" PRIx64 " previous=%p\n",
|
||||
vaddr, size, cached->Address(), cached->Size(),
|
||||
static_cast<const void*>(found));
|
||||
vaddr, size, cached->Address(), cached->Size(), static_cast<const void*>(found));
|
||||
}
|
||||
found = cached;
|
||||
}
|
||||
@@ -2804,8 +2787,7 @@ RenderTextureVulkanImage* TextureCache::FindRenderTargetByRange(CommandBuffer* c
|
||||
TextureCache::RegionInfo TextureCache::QueryRegion(uint64_t vaddr, uint64_t size) {
|
||||
if (vaddr == 0 || size == 0 || vaddr >= TRACKER_ADDRESS_SIZE ||
|
||||
size > TRACKER_ADDRESS_SIZE - vaddr) {
|
||||
EXIT("TextureCache: invalid region query, addr=0x%016" PRIx64
|
||||
" size=0x%016" PRIx64 "\n",
|
||||
EXIT("TextureCache: invalid region query, addr=0x%016" PRIx64 " size=0x%016" PRIx64 "\n",
|
||||
vaddr, size);
|
||||
}
|
||||
FaultSafeTextureLock lock(this, m_lock);
|
||||
|
||||
@@ -139,8 +139,8 @@ private:
|
||||
void UnregisterImageLocked(CachedImage& image, bool release_tracking);
|
||||
[[nodiscard]] VulkanImage* PublishImage(CommandBuffer* command,
|
||||
std::shared_ptr<CachedImage> image);
|
||||
[[nodiscard]] std::vector<CachedImage*>
|
||||
FindImagesInRegionLocked(uint64_t vaddr, uint64_t size, bool page_overlap);
|
||||
[[nodiscard]] std::vector<CachedImage*> FindImagesInRegionLocked(uint64_t vaddr, uint64_t size,
|
||||
bool page_overlap);
|
||||
void RequireRetirementIsolation(const std::vector<CachedImage*>& retire, const char* operation,
|
||||
uint64_t address, uint64_t size) const;
|
||||
void RetireImages(const std::vector<CachedImage*>& retire,
|
||||
|
||||
@@ -172,29 +172,29 @@ void Tiler::TileImage(void* dst, const void* src, const RenderTargetInfo& info)
|
||||
}
|
||||
|
||||
void Tiler::TileImage(void* dst, const void* src, const ImageInfo& info) const {
|
||||
const bool image_2d = info.type == Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) &&
|
||||
info.depth == 1;
|
||||
const bool image_2d =
|
||||
info.type == Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) && info.depth == 1;
|
||||
const auto bytes_per_element = Prospero::RenderTargetBytesPerElement(info.format);
|
||||
if (!image_2d || info.levels == 0 || info.levels > 16 ||
|
||||
info.tile != Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget) ||
|
||||
bytes_per_element == 0) {
|
||||
EXIT("Tiler: unsupported storage-texture tile, addr=0x%016" PRIx64
|
||||
"+0x%016" PRIx64 " extent=%ux%ux%u levels=%u tile=%u format=%u\n",
|
||||
EXIT("Tiler: unsupported storage-texture tile, addr=0x%016" PRIx64 "+0x%016" PRIx64
|
||||
" extent=%ux%ux%u levels=%u tile=%u format=%u\n",
|
||||
info.address, info.size, info.width, info.height, info.depth, info.levels, info.tile,
|
||||
info.format);
|
||||
}
|
||||
auto layout = TextureCalcUploadLayout(info.format, info.width, info.height, info.levels,
|
||||
info.depth, info.pitch, info.tile, info.size, true, false,
|
||||
false, "StorageTextureReadback");
|
||||
auto regions = TextureBuildUploadRegions(
|
||||
layout, Prospero::SurfaceFormat(info.format), info.width, info.height, info.depth,
|
||||
info.levels, false, false, TextureUploadDestination::MipLevels,
|
||||
auto regions = TextureBuildUploadRegions(layout, Prospero::SurfaceFormat(info.format),
|
||||
info.width, info.height, info.depth, info.levels,
|
||||
false, false, TextureUploadDestination::MipLevels,
|
||||
TextureUploadSliceLayout::MipChainPerSlice);
|
||||
std::memset(dst, 0, info.size);
|
||||
for (uint32_t level = 0; level < info.levels; level++) {
|
||||
const auto& level_size = layout.level_sizes[level];
|
||||
const auto guest_offset = level_size.src_size != 0 ? level_size.src_offset
|
||||
: level_size.offset;
|
||||
const auto guest_offset =
|
||||
level_size.src_size != 0 ? level_size.src_offset : level_size.offset;
|
||||
auto* guest = static_cast<uint8_t*>(dst) + guest_offset;
|
||||
const auto* linear = static_cast<const uint8_t*>(src) + regions[level].offset;
|
||||
TileConvertLinearToTiledRenderTarget(
|
||||
|
||||
@@ -92,8 +92,7 @@ void UtilCopyImageWithBuffer(CommandBuffer* buffer, GraphicContext* ctx, VulkanI
|
||||
uint64_t dst_layout);
|
||||
void UtilBlitPreparedImage(CommandBuffer* buffer, VulkanImage* src_image,
|
||||
VulkanSwapchain* dst_swapchain);
|
||||
void UtilClearColorImage(CommandBuffer* buffer, VulkanImage* image,
|
||||
const VkClearColorValue& color);
|
||||
void UtilClearColorImage(CommandBuffer* buffer, VulkanImage* image, const VkClearColorValue& color);
|
||||
void UtilFillImage(GraphicContext* ctx, VulkanImage* dst_image, const void* src_data, uint64_t size,
|
||||
uint32_t src_pitch, uint64_t dst_layout);
|
||||
void UtilFillImage(GraphicContext* ctx, DepthStencilVulkanImage* dst_image, const void* src_data,
|
||||
|
||||
@@ -385,7 +385,8 @@ static void VulkanRecreateSwapchain() {
|
||||
}
|
||||
|
||||
static void ValidatePreparedCommand(CommandBuffer* buffer) {
|
||||
if (buffer == nullptr || buffer->IsInvalid() || buffer->GetQueue() != GraphicContext::QUEUE_GFX) {
|
||||
if (buffer == nullptr || buffer->IsInvalid() ||
|
||||
buffer->GetQueue() != GraphicContext::QUEUE_GFX) {
|
||||
EXIT("prepared frames must be recorded on the graphics queue\n");
|
||||
}
|
||||
EXIT_IF(g_render_ctx == nullptr);
|
||||
|
||||
@@ -27,7 +27,8 @@ struct BufferFormatInfo {
|
||||
};
|
||||
|
||||
constexpr Prospero::BufferFormat DecodeTBufferFormat(uint32_t data_format, uint32_t number_format) {
|
||||
return static_cast<Prospero::BufferFormat>(((number_format & 0x7u) << 4u) | (data_format & 0xfu));
|
||||
return static_cast<Prospero::BufferFormat>(((number_format & 0x7u) << 4u) |
|
||||
(data_format & 0xfu));
|
||||
}
|
||||
|
||||
constexpr ComponentType GetFormatComponentType(Prospero::BufferFormat format) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "graphics/shader/recompiler/ShaderIR.h"
|
||||
|
||||
#include "graphics/shader/recompiler/shaderIR/ShaderIRInternal.h"
|
||||
#include "common/assert.h"
|
||||
#include "graphics/shader/recompiler/BufferFormat.h"
|
||||
#include "graphics/shader/recompiler/shaderIR/ShaderIRInternal.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <fmt/format.h>
|
||||
@@ -403,7 +403,6 @@ Decoder::Operand M0Operand() {
|
||||
return operand;
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
bool LowerScalarSelect(const Decoder::Instruction& decoded, BasicBlock* block, std::string* error) {
|
||||
@@ -1145,7 +1144,6 @@ bool LowerDecodedInstruction(const Decoder::Instruction& inst, BasicBlock* block
|
||||
return LowerImplemented(inst, block, error);
|
||||
}
|
||||
|
||||
|
||||
bool LowerImplemented(const Decoder::Instruction& decoded, BasicBlock* block, std::string* error) {
|
||||
Instruction inst;
|
||||
inst.pc = decoded.pc;
|
||||
|
||||
@@ -21,8 +21,7 @@ bool AppendScalarResultSccNonZero(const Decoder::Instruction& decoded, BasicB
|
||||
std::string* error);
|
||||
uint32_t VectorByteConvertIndex(Decoder::Opcode opcode);
|
||||
void CopyOperandModifiers(const Decoder::Operand& decoded, Operand& operand);
|
||||
bool LowerRegisterOperand(const Decoder::Operand& decoded, Operand* operand,
|
||||
std::string* error);
|
||||
bool LowerRegisterOperand(const Decoder::Operand& decoded, Operand* operand, std::string* error);
|
||||
bool LowerSourceOperand(const Decoder::Operand& decoded, Operand* operand, std::string* error);
|
||||
void ApplyDppDestinationMask(const Decoder::Instruction& decoded, Operand& dst);
|
||||
uint32_t ResourceIndexFromOperand(const Decoder::Operand& operand);
|
||||
@@ -40,8 +39,7 @@ uint32_t TypedBufferComponentOffsetBytes(const Decoder::Instruction& decoded,
|
||||
uint32_t TypedBufferFormatComponentCount(const Decoder::Instruction& decoded);
|
||||
bool LowerMoveImmediateU32(uint32_t pc, const Decoder::Operand& dst, uint32_t value,
|
||||
BasicBlock* block, std::string* error);
|
||||
MemoryInfo OffsetBufferMemoryInfo(const Decoder::Instruction& decoded,
|
||||
uint32_t component_index);
|
||||
MemoryInfo OffsetBufferMemoryInfo(const Decoder::Instruction& decoded, uint32_t component_index);
|
||||
MemoryInfo ByteOffsetMemoryInfo(const Decoder::Instruction& decoded, ResourceKind kind,
|
||||
uint32_t byte_offset);
|
||||
ResourceKind FlatSegmentResourceKind(uint32_t segment);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "graphics/shader/recompiler/ShaderIR.h"
|
||||
|
||||
#include "graphics/shader/recompiler/shaderIR/ShaderIRInternal.h"
|
||||
#include "common/assert.h"
|
||||
#include "graphics/shader/recompiler/BufferFormat.h"
|
||||
#include "graphics/shader/recompiler/ShaderIR.h"
|
||||
#include "graphics/shader/recompiler/shaderIR/ShaderIRInternal.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <fmt/format.h>
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "graphics/shader/recompiler/ShaderIR.h"
|
||||
|
||||
#include "graphics/shader/recompiler/shaderIR/ShaderIRInternal.h"
|
||||
#include "common/assert.h"
|
||||
#include "graphics/shader/recompiler/BufferFormat.h"
|
||||
#include "graphics/shader/recompiler/ShaderIR.h"
|
||||
#include "graphics/shader/recompiler/shaderIR/ShaderIRInternal.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <fmt/format.h>
|
||||
@@ -470,7 +469,6 @@ bool LowerImageOperation(const Decoder::Instruction& decoded, BasicBlock* block,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
bool LowerMemoryInstruction(const Decoder::Instruction& decoded, BasicBlock* block,
|
||||
@@ -647,7 +645,6 @@ bool LowerMemoryInstruction(const Decoder::Instruction& decoded, BasicBlock* blo
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool IsMemoryOpcode(Decoder::Opcode opcode) {
|
||||
switch (opcode) {
|
||||
case Decoder::Opcode::SLoadDword:
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "graphics/shader/recompiler/ShaderIR.h"
|
||||
|
||||
#include "graphics/shader/recompiler/shaderIR/ShaderIRInternal.h"
|
||||
#include "common/assert.h"
|
||||
#include "graphics/shader/recompiler/BufferFormat.h"
|
||||
#include "graphics/shader/recompiler/ShaderIR.h"
|
||||
#include "graphics/shader/recompiler/shaderIR/ShaderIRInternal.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <fmt/format.h>
|
||||
@@ -425,7 +424,6 @@ constexpr LowerMap LOWER_OPS[] = {
|
||||
{Decoder::Opcode::ImageGather4H, Opcode::ImageGather4},
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
void SetError(std::string* error, const char* message) {
|
||||
|
||||
@@ -913,9 +913,11 @@ uint32_t AddressSourceCount(const IR::Instruction& inst, uint32_t first_src);
|
||||
|
||||
bool IsFormattedBufferComponent(const IR::Instruction& inst);
|
||||
|
||||
Prospero::BufferFormat FormattedBufferFormat(const EmitterState& state, const IR::Instruction& inst);
|
||||
Prospero::BufferFormat FormattedBufferFormat(const EmitterState& state,
|
||||
const IR::Instruction& inst);
|
||||
|
||||
IR::Instruction WithFormatComponentByteOffset(const IR::Instruction& inst, Prospero::BufferFormat format);
|
||||
IR::Instruction WithFormatComponentByteOffset(const IR::Instruction& inst,
|
||||
Prospero::BufferFormat format);
|
||||
|
||||
uint32_t EmitTBufferBitcastF32ToU32(EmitterState* state, uint32_t value);
|
||||
|
||||
|
||||
@@ -726,13 +726,16 @@ bool IsFormattedBufferComponent(const IR::Instruction& inst) {
|
||||
inst.memory.data_dwords == 1u;
|
||||
}
|
||||
|
||||
Prospero::BufferFormat FormattedBufferFormat(const EmitterState& state, const IR::Instruction& inst) {
|
||||
Prospero::BufferFormat FormattedBufferFormat(const EmitterState& state,
|
||||
const IR::Instruction& inst) {
|
||||
return inst.memory.typed
|
||||
? Format::DecodeTBufferFormat(inst.memory.data_format, inst.memory.number_format)
|
||||
: static_cast<Prospero::BufferFormat>(StorageBufferFormat(state, inst.memory, inst.pc));
|
||||
: static_cast<Prospero::BufferFormat>(
|
||||
StorageBufferFormat(state, inst.memory, inst.pc));
|
||||
}
|
||||
|
||||
IR::Instruction WithFormatComponentByteOffset(const IR::Instruction& inst, Prospero::BufferFormat format) {
|
||||
IR::Instruction WithFormatComponentByteOffset(const IR::Instruction& inst,
|
||||
Prospero::BufferFormat format) {
|
||||
auto rebased = inst;
|
||||
if (inst.memory.typed || inst.memory.component_index == 0u) {
|
||||
return rebased;
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include "common/magicEnum.h"
|
||||
#include "common/profiler.h"
|
||||
#include "common/stringUtils.h"
|
||||
#include "graphics/guest_gpu/gpu_defs.h"
|
||||
#include "graphics/guest_gpu/graphicsRun.h"
|
||||
#include "graphics/guest_gpu/hardwareContext.h"
|
||||
#include "graphics/guest_gpu/gpu_defs.h"
|
||||
#include "graphics/shader/recompiler/ShaderDecoder.h"
|
||||
#include "graphics/shader/recompiler/ShaderRecompiler.h"
|
||||
#include "graphics/shader/shaderVertexMetadata.h"
|
||||
@@ -562,14 +562,18 @@ static uint32_t VertexAttribFormatToBufferFormat(uint32_t format) {
|
||||
{Prospero::VertexAttribFormat::k10_11_11Float, Prospero::BufferFormat::k10_11_11Float},
|
||||
{Prospero::VertexAttribFormat::k2_10_10_10UNorm, Prospero::BufferFormat::k2_10_10_10UNorm},
|
||||
{Prospero::VertexAttribFormat::k2_10_10_10SNorm, Prospero::BufferFormat::k2_10_10_10SNorm},
|
||||
{Prospero::VertexAttribFormat::k2_10_10_10UScaled, Prospero::BufferFormat::k2_10_10_10UScaled},
|
||||
{Prospero::VertexAttribFormat::k2_10_10_10SScaled, Prospero::BufferFormat::k2_10_10_10SScaled},
|
||||
{Prospero::VertexAttribFormat::k2_10_10_10UScaled,
|
||||
Prospero::BufferFormat::k2_10_10_10UScaled},
|
||||
{Prospero::VertexAttribFormat::k2_10_10_10SScaled,
|
||||
Prospero::BufferFormat::k2_10_10_10SScaled},
|
||||
{Prospero::VertexAttribFormat::k2_10_10_10UInt, Prospero::BufferFormat::k2_10_10_10UInt},
|
||||
{Prospero::VertexAttribFormat::k2_10_10_10SInt, Prospero::BufferFormat::k2_10_10_10SInt},
|
||||
{Prospero::VertexAttribFormat::k10_10_10_2UNorm, Prospero::BufferFormat::k10_10_10_2UNorm},
|
||||
{Prospero::VertexAttribFormat::k10_10_10_2SNorm, Prospero::BufferFormat::k10_10_10_2SNorm},
|
||||
{Prospero::VertexAttribFormat::k10_10_10_2UScaled, Prospero::BufferFormat::k10_10_10_2UScaled},
|
||||
{Prospero::VertexAttribFormat::k10_10_10_2SScaled, Prospero::BufferFormat::k10_10_10_2SScaled},
|
||||
{Prospero::VertexAttribFormat::k10_10_10_2UScaled,
|
||||
Prospero::BufferFormat::k10_10_10_2UScaled},
|
||||
{Prospero::VertexAttribFormat::k10_10_10_2SScaled,
|
||||
Prospero::BufferFormat::k10_10_10_2SScaled},
|
||||
{Prospero::VertexAttribFormat::k10_10_10_2UInt, Prospero::BufferFormat::k10_10_10_2UInt},
|
||||
{Prospero::VertexAttribFormat::k10_10_10_2SInt, Prospero::BufferFormat::k10_10_10_2SInt},
|
||||
{Prospero::VertexAttribFormat::k8_8_8_8UNorm, Prospero::BufferFormat::k8_8_8_8UNorm},
|
||||
@@ -581,19 +585,25 @@ static uint32_t VertexAttribFormatToBufferFormat(uint32_t format) {
|
||||
{Prospero::VertexAttribFormat::k32_32UInt, Prospero::BufferFormat::k32_32UInt},
|
||||
{Prospero::VertexAttribFormat::k32_32SInt, Prospero::BufferFormat::k32_32SInt},
|
||||
{Prospero::VertexAttribFormat::k32_32Float, Prospero::BufferFormat::k32_32Float},
|
||||
{Prospero::VertexAttribFormat::k16_16_16_16UNorm, Prospero::BufferFormat::k16_16_16_16UNorm},
|
||||
{Prospero::VertexAttribFormat::k16_16_16_16SNorm, Prospero::BufferFormat::k16_16_16_16SNorm},
|
||||
{Prospero::VertexAttribFormat::k16_16_16_16UScaled, Prospero::BufferFormat::k16_16_16_16UScaled},
|
||||
{Prospero::VertexAttribFormat::k16_16_16_16SScaled, Prospero::BufferFormat::k16_16_16_16SScaled},
|
||||
{Prospero::VertexAttribFormat::k16_16_16_16UNorm,
|
||||
Prospero::BufferFormat::k16_16_16_16UNorm},
|
||||
{Prospero::VertexAttribFormat::k16_16_16_16SNorm,
|
||||
Prospero::BufferFormat::k16_16_16_16SNorm},
|
||||
{Prospero::VertexAttribFormat::k16_16_16_16UScaled,
|
||||
Prospero::BufferFormat::k16_16_16_16UScaled},
|
||||
{Prospero::VertexAttribFormat::k16_16_16_16SScaled,
|
||||
Prospero::BufferFormat::k16_16_16_16SScaled},
|
||||
{Prospero::VertexAttribFormat::k16_16_16_16UInt, Prospero::BufferFormat::k16_16_16_16UInt},
|
||||
{Prospero::VertexAttribFormat::k16_16_16_16SInt, Prospero::BufferFormat::k16_16_16_16SInt},
|
||||
{Prospero::VertexAttribFormat::k16_16_16_16Float, Prospero::BufferFormat::k16_16_16_16Float},
|
||||
{Prospero::VertexAttribFormat::k16_16_16_16Float,
|
||||
Prospero::BufferFormat::k16_16_16_16Float},
|
||||
{Prospero::VertexAttribFormat::k32_32_32UInt, Prospero::BufferFormat::k32_32_32UInt},
|
||||
{Prospero::VertexAttribFormat::k32_32_32SInt, Prospero::BufferFormat::k32_32_32SInt},
|
||||
{Prospero::VertexAttribFormat::k32_32_32Float, Prospero::BufferFormat::k32_32_32Float},
|
||||
{Prospero::VertexAttribFormat::k32_32_32_32UInt, Prospero::BufferFormat::k32_32_32_32UInt},
|
||||
{Prospero::VertexAttribFormat::k32_32_32_32SInt, Prospero::BufferFormat::k32_32_32_32SInt},
|
||||
{Prospero::VertexAttribFormat::k32_32_32_32Float, Prospero::BufferFormat::k32_32_32_32Float},
|
||||
{Prospero::VertexAttribFormat::k32_32_32_32Float,
|
||||
Prospero::BufferFormat::k32_32_32_32Float},
|
||||
};
|
||||
|
||||
for (const auto& entry: format_map) {
|
||||
@@ -835,8 +845,8 @@ static void ShaderGetStaticInputInfoPS(
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ps_info->target_output_mode[i] = sh->target_output_mode[i];
|
||||
ps_info->target_export_mapping[i] =
|
||||
sh->target_output_mode[i] != 0 ? target_export_mapping[i]
|
||||
ps_info->target_export_mapping[i] = sh->target_output_mode[i] != 0
|
||||
? target_export_mapping[i]
|
||||
: Prospero::ColorComponentMapping {};
|
||||
}
|
||||
ps_info->mrt_output_mask = 0;
|
||||
|
||||
@@ -39,10 +39,10 @@
|
||||
#include <QUrl>
|
||||
#include <QtCore>
|
||||
|
||||
#include "ui_configuration_list_widget.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "ui_configuration_list_widget.h"
|
||||
|
||||
constexpr char CONF_FILE_NAME[] = "Kyty.ini";
|
||||
constexpr char CONF_ORG_NAME[] = "Kyty";
|
||||
constexpr char CONF_APP_NAME[] = "Kyty";
|
||||
|
||||
+15
-8
@@ -6,10 +6,10 @@
|
||||
#include "common/logging/log.h"
|
||||
#include "common/stringUtils.h"
|
||||
#include "common/virtualMemory.h"
|
||||
#include "graphics/guest_gpu/gpu_defs.h"
|
||||
#include "graphics/guest_gpu/graphicsRun.h"
|
||||
#include "graphics/guest_gpu/hardwareContext.h"
|
||||
#include "graphics/guest_gpu/pm4.h"
|
||||
#include "graphics/guest_gpu/gpu_defs.h"
|
||||
#include "graphics/guest_gpu/tile.h"
|
||||
#include "graphics/host_gpu/objects/label.h"
|
||||
#include "graphics/host_gpu/renderer/render.h"
|
||||
@@ -575,8 +575,12 @@ static bool get_shader_program_address_register(uint8_t type, uint32_t* lo_offse
|
||||
case Prospero::ShaderBinaryType::kPs: *lo_offset = Pm4::SPI_SHADER_PGM_LO_PS; return true;
|
||||
case Prospero::ShaderBinaryType::kGs: *lo_offset = Pm4::SPI_SHADER_PGM_LO_ES; return true;
|
||||
case Prospero::ShaderBinaryType::kHs: *lo_offset = Pm4::SPI_SHADER_PGM_LO_LS; return true;
|
||||
case Prospero::ShaderBinaryType::kGsBack: *lo_offset = Pm4::SPI_SHADER_PGM_LO_GS; return true;
|
||||
case Prospero::ShaderBinaryType::kHsBack: *lo_offset = Pm4::SPI_SHADER_PGM_LO_HS; return true;
|
||||
case Prospero::ShaderBinaryType::kGsBack:
|
||||
*lo_offset = Pm4::SPI_SHADER_PGM_LO_GS;
|
||||
return true;
|
||||
case Prospero::ShaderBinaryType::kHsBack:
|
||||
*lo_offset = Pm4::SPI_SHADER_PGM_LO_HS;
|
||||
return true;
|
||||
case Prospero::ShaderBinaryType::kGsFront:
|
||||
case Prospero::ShaderBinaryType::kHsFront:
|
||||
case Prospero::ShaderBinaryType::kFs: return false;
|
||||
@@ -1016,12 +1020,14 @@ int KYTY_SYSV_ABI GraphicsSetUcRegIndirectPatchAddRegisters(uint32_t* cmd, uint3
|
||||
|
||||
static uint32_t GraphicsPrimitiveTypeToGsOut(uint32_t prim_type) {
|
||||
switch (static_cast<Prospero::PrimitiveType>(prim_type)) {
|
||||
case Prospero::PrimitiveType::kPointList: return Prospero::GpuEnumValue(Prospero::GsOutputPrimitiveType::kPoints);
|
||||
case Prospero::PrimitiveType::kPointList:
|
||||
return Prospero::GpuEnumValue(Prospero::GsOutputPrimitiveType::kPoints);
|
||||
case Prospero::PrimitiveType::kLineList:
|
||||
case Prospero::PrimitiveType::kLineStrip:
|
||||
case Prospero::PrimitiveType::kLineListAdjacency:
|
||||
case Prospero::PrimitiveType::kLineStripAdjacency:
|
||||
case Prospero::PrimitiveType::kLineLoop: return Prospero::GpuEnumValue(Prospero::GsOutputPrimitiveType::kLines);
|
||||
case Prospero::PrimitiveType::kLineLoop:
|
||||
return Prospero::GpuEnumValue(Prospero::GsOutputPrimitiveType::kLines);
|
||||
case Prospero::PrimitiveType::kRectList:
|
||||
return Prospero::GpuEnumValue(Prospero::GsOutputPrimitiveType::k2dRectangle);
|
||||
case Prospero::PrimitiveType::kRectListLegacy:
|
||||
@@ -1048,9 +1054,10 @@ int KYTY_SYSV_ABI GraphicsCreatePrimState(ShaderRegister* cx_regs, ShaderRegiste
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(gs == nullptr);
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(hs != nullptr &&
|
||||
static_cast<Prospero::ShaderBinaryType>(hs->type) != Prospero::ShaderBinaryType::kHs);
|
||||
EXIT_NOT_IMPLEMENTED(static_cast<Prospero::ShaderBinaryType>(gs->type) != Prospero::ShaderBinaryType::kGs);
|
||||
EXIT_NOT_IMPLEMENTED(hs != nullptr && static_cast<Prospero::ShaderBinaryType>(hs->type) !=
|
||||
Prospero::ShaderBinaryType::kHs);
|
||||
EXIT_NOT_IMPLEMENTED(static_cast<Prospero::ShaderBinaryType>(gs->type) !=
|
||||
Prospero::ShaderBinaryType::kGs);
|
||||
|
||||
if (cx_regs != nullptr) {
|
||||
EXIT_NOT_IMPLEMENTED(hs != nullptr && hs->specials->vgt_shader_stages_en.offset !=
|
||||
|
||||
+852
-794
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user