mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 02:47:02 +02:00
graphics: support PS5 1D color render targets
This commit is contained in:
@@ -6997,6 +6997,106 @@ public:
|
||||
std::printf("[gpu] %-32s ok\n", name);
|
||||
}
|
||||
|
||||
void CheckRenderExecutorColor1DDiscovery() {
|
||||
constexpr const char *name = "RenderExecutorColor1DDiscovery";
|
||||
constexpr uintptr_t base = 0x0000000203c00000ull;
|
||||
constexpr uint32_t width = 512;
|
||||
constexpr uint32_t height = 1;
|
||||
constexpr uint32_t bytes_per_element = 4;
|
||||
constexpr uint64_t allocation_alignment = 0x10000;
|
||||
EnsureRuntimeContext();
|
||||
|
||||
const auto pitch =
|
||||
TileGetRenderTargetPitch(width, bytes_per_element, 0);
|
||||
TileSizeAlign layout{};
|
||||
Require(name, "tile layout",
|
||||
pitch != 0 && TileGetRenderTargetSize(
|
||||
width, height, pitch, bytes_per_element, layout, 0),
|
||||
"1D render-target layout is unavailable");
|
||||
const auto allocation_size =
|
||||
std::max<uint64_t>(layout.size, allocation_alignment);
|
||||
|
||||
int64_t direct_offset = -1;
|
||||
Require(name, "direct allocation",
|
||||
Libs::LibKernel::Memory::KernelAllocateDirectMemory(
|
||||
0, Libs::LibKernel::Memory::KernelGetDirectMemorySize(),
|
||||
allocation_size, allocation_alignment, 0, &direct_offset) == 0,
|
||||
"1D color direct-memory allocation failed");
|
||||
void *mapped = reinterpret_cast<void *>(base);
|
||||
Require(name, "direct mapping",
|
||||
Libs::LibKernel::Memory::KernelMapDirectMemory(
|
||||
&mapped, allocation_size, 0x3, 0x10, direct_offset,
|
||||
allocation_alignment) == 0 &&
|
||||
mapped == reinterpret_cast<void *>(base),
|
||||
"1D color fixed mapping failed");
|
||||
std::memset(mapped, 0, allocation_size);
|
||||
|
||||
{
|
||||
RenderContext context(m_runtime_context);
|
||||
auto &scheduler = context.GetCommandScheduler();
|
||||
HW::Context registers{};
|
||||
HW::UserConfig user_config{};
|
||||
HW::Shader shaders{};
|
||||
registers.SetColorBase(0, {.addr = base});
|
||||
registers.SetColorInfo(
|
||||
0, {.format = Prospero::ChannelLayout::k8_8_8_8,
|
||||
.channel_type = Prospero::ChannelType::kSrgb,
|
||||
.channel_order = Prospero::ChannelOrder::kStandard});
|
||||
registers.SetColorAttrib2(0, {.height = height - 1, .width = width - 1});
|
||||
registers.SetColorAttrib3(0,
|
||||
{.tile_mode = Prospero::TileMode::kRenderTarget,
|
||||
.dimension = 0,
|
||||
.cmask_pipe_aligned = true,
|
||||
.dcc_pipe_aligned = true});
|
||||
registers.SetRenderTargetMask(0x0f);
|
||||
scheduler.Begin(registers, user_config, shaders);
|
||||
|
||||
auto &resources = context.GetGpuResources();
|
||||
auto &texture_cache = resources.GetTextureCache();
|
||||
auto &executor = context.GetRenderExecutor();
|
||||
resources.MapMemory(base, allocation_size);
|
||||
|
||||
RenderColorInfo color{};
|
||||
RenderExecutorTestAccess::ResolveRenderColorTarget(
|
||||
executor, 1, scheduler.Current(), color, 0);
|
||||
const auto attachment =
|
||||
texture_cache.FindRenderTarget(color.image_id, color.desc);
|
||||
const auto &image = texture_cache.GetImage(color.image_id);
|
||||
RenderDepthInfo no_depth{};
|
||||
const auto rendering = RenderExecutorTestAccess::AcquireRenderTargets(
|
||||
executor, scheduler.Current(), &color, 1, no_depth);
|
||||
scheduler.Current().BeginRendering(rendering);
|
||||
scheduler.Current().EndRendering();
|
||||
Require(name, "captured 1D target",
|
||||
color.image_id && attachment != nullptr &&
|
||||
color.image_view != nullptr &&
|
||||
color.desc.info.type == Prospero::ImageType::kColor1D &&
|
||||
color.desc.info.extent == vk::Extent3D{width, height, 1} &&
|
||||
color.desc.info.resources == ImageSubresources{1, 1} &&
|
||||
color.desc.info.pitch == pitch &&
|
||||
color.desc.info.data.size == layout.size &&
|
||||
color.desc.view_info.type == vk::ImageViewType::e1D &&
|
||||
image.backing.image_type == vk::ImageType::e1D &&
|
||||
rendering.width == width && rendering.height == height &&
|
||||
rendering.num_layers == 1 &&
|
||||
rendering.num_color_attachments == 1,
|
||||
"SDK dimension=0 did not create a 512x1 Vulkan attachment");
|
||||
|
||||
RenderExecutorTestAccess::ResetBindings(executor);
|
||||
resources.UnmapMemory(base, allocation_size);
|
||||
scheduler.Finish();
|
||||
}
|
||||
|
||||
Require(name, "unmap direct backing",
|
||||
Libs::LibKernel::Memory::KernelMunmap(base, allocation_size) == 0,
|
||||
"1D color direct mapping release failed");
|
||||
Require(name, "release direct backing",
|
||||
Libs::LibKernel::Memory::KernelReleaseDirectMemory(
|
||||
direct_offset, allocation_size) == 0,
|
||||
"1D color direct-memory allocation release failed");
|
||||
std::printf("[gpu] %-32s ok\n", name);
|
||||
}
|
||||
|
||||
void CheckRenderExecutorColorVolumeDiscovery() {
|
||||
constexpr const char *name = "RenderExecutorColorVolumeDiscovery";
|
||||
constexpr uintptr_t base = 0x0000000203e00000ull;
|
||||
@@ -24237,6 +24337,7 @@ int main(int argc, char **argv) {
|
||||
CheckDepthAttachmentWrites();
|
||||
CheckDynamicRenderingState();
|
||||
VulkanHarness vulkan;
|
||||
vulkan.CheckRenderExecutorColor1DDiscovery();
|
||||
vulkan.CheckRenderExecutorColorVolumeDiscovery();
|
||||
vulkan.CheckRenderExecutorColorDepthTileDiscovery();
|
||||
vulkan.CheckRenderExecutorStencilBindingDiscovery();
|
||||
@@ -24411,6 +24512,7 @@ int main(int argc, char **argv) {
|
||||
vulkan.CheckStreamBufferRing();
|
||||
vulkan.CheckGpuTilerCpuParity();
|
||||
#if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS
|
||||
vulkan.CheckRenderExecutorColor1DDiscovery();
|
||||
vulkan.CheckRenderExecutorColorVolumeDiscovery();
|
||||
vulkan.CheckRenderExecutorColorStandard4TileDiscovery();
|
||||
vulkan.CheckRenderExecutorColorDepthTileDiscovery();
|
||||
|
||||
Reference in New Issue
Block a user