mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-25 22:57:22 +00:00
include some debug info
This commit is contained in:
parent
03ce2d3e7d
commit
a11d1aa38a
7 changed files with 57 additions and 91 deletions
|
@ -17,6 +17,7 @@ struct PixelFormatInfo {
|
|||
MTL::PixelFormat pixel_format;
|
||||
size_t bytes_per_block;
|
||||
VideoCommon::Extent2D block_texel_size{1, 1};
|
||||
bool can_be_render_target = true;
|
||||
};
|
||||
|
||||
// TODO: replace some of the invalid formats with the correct ones and emulate those which don't map
|
||||
|
@ -46,17 +47,17 @@ constexpr std::array<PixelFormatInfo, VideoCore::Surface::MaxPixelFormat> FORMAT
|
|||
{MTL::PixelFormatRGBA16Uint, 8}, // R16G16B16A16_UINT
|
||||
{MTL::PixelFormatInvalid, 0}, // B10G11R11_FLOAT
|
||||
{MTL::PixelFormatRGBA32Uint, 16}, // R32G32B32A32_UINT
|
||||
{MTL::PixelFormatBC1_RGBA, 8, {4, 4}}, // BC1_RGBA_UNORM
|
||||
{MTL::PixelFormatBC1_RGBA, 8, {4, 4}, false}, // BC1_RGBA_UNORM
|
||||
{MTL::PixelFormatInvalid, 0}, // BC2_UNORM
|
||||
{MTL::PixelFormatInvalid, 0}, // BC3_UNORM
|
||||
{MTL::PixelFormatBC4_RUnorm, 8, {4, 4}}, // BC4_UNORM
|
||||
{MTL::PixelFormatBC4_RSnorm, 0}, // BC4_SNORM
|
||||
{MTL::PixelFormatBC4_RUnorm, 8, {4, 4}, false}, // BC4_UNORM
|
||||
{MTL::PixelFormatBC4_RSnorm, 0, {0, 0}, false}, // BC4_SNORM TODO
|
||||
{MTL::PixelFormatInvalid, 0}, // BC5_UNORM
|
||||
{MTL::PixelFormatInvalid, 0}, // BC5_SNORM
|
||||
{MTL::PixelFormatInvalid, 0}, // BC7_UNORM
|
||||
{MTL::PixelFormatInvalid, 0}, // BC6H_UFLOAT
|
||||
{MTL::PixelFormatInvalid, 0}, // BC6H_SFLOAT
|
||||
{MTL::PixelFormatASTC_4x4_LDR, 0}, // ASTC_2D_4X4_UNORM
|
||||
{MTL::PixelFormatASTC_4x4_LDR, 0, {0, 0}, false}, // ASTC_2D_4X4_UNORM TODO
|
||||
{MTL::PixelFormatBGRA8Unorm, 4}, // B8G8R8A8_UNORM
|
||||
{MTL::PixelFormatRGBA32Float, 16}, // R32G32B32A32_FLOAT
|
||||
{MTL::PixelFormatRGBA32Sint, 16}, // R32G32B32A32_SINT
|
||||
|
@ -83,40 +84,40 @@ constexpr std::array<PixelFormatInfo, VideoCore::Surface::MaxPixelFormat> FORMAT
|
|||
{MTL::PixelFormatInvalid, 0}, // R16G16B16X16_FLOAT
|
||||
{MTL::PixelFormatR32Uint, 4}, // R32_UINT
|
||||
{MTL::PixelFormatR32Sint, 4}, // R32_SINT
|
||||
{MTL::PixelFormatASTC_8x8_LDR, 16, {8, 8}}, // ASTC_2D_8X8_UNORM
|
||||
{MTL::PixelFormatASTC_8x5_LDR, 0}, // ASTC_2D_8X5_UNORM
|
||||
{MTL::PixelFormatASTC_5x4_LDR, 0}, // ASTC_2D_5X4_UNORM
|
||||
{MTL::PixelFormatASTC_8x8_LDR, 16, {8, 8}, false}, // ASTC_2D_8X8_UNORM
|
||||
{MTL::PixelFormatASTC_8x5_LDR, 0, {0, 0}, false}, // ASTC_2D_8X5_UNORM TODO
|
||||
{MTL::PixelFormatASTC_5x4_LDR, 0, {0, 0}, false}, // ASTC_2D_5X4_UNORM TODO
|
||||
{MTL::PixelFormatBGRA8Unorm_sRGB, 0}, // B8G8R8A8_SRGB
|
||||
{MTL::PixelFormatBC1_RGBA_sRGB, 0}, // BC1_RGBA_SRGB
|
||||
{MTL::PixelFormatBC1_RGBA_sRGB, 0, {0, 0}, false}, // BC1_RGBA_SRGB TODO
|
||||
{MTL::PixelFormatInvalid, 0}, // BC2_SRGB
|
||||
{MTL::PixelFormatInvalid, 0}, // BC3_SRGB
|
||||
{MTL::PixelFormatBC7_RGBAUnorm_sRGB, 0}, // BC7_SRGB
|
||||
{MTL::PixelFormatBC7_RGBAUnorm_sRGB, 0, {0, 0}, false}, // BC7_SRGB TODO
|
||||
{MTL::PixelFormatABGR4Unorm, 0}, // A4B4G4R4_UNORM
|
||||
{MTL::PixelFormatInvalid, 0}, // G4R4_UNORM
|
||||
{MTL::PixelFormatASTC_4x4_sRGB, 16, {4, 4}}, // ASTC_2D_4X4_SRGB
|
||||
{MTL::PixelFormatASTC_8x8_sRGB, 0}, // ASTC_2D_8X8_SRGB
|
||||
{MTL::PixelFormatASTC_8x5_sRGB, 0}, // ASTC_2D_8X5_SRGB
|
||||
{MTL::PixelFormatASTC_5x4_sRGB, 0}, // ASTC_2D_5X4_SRGB
|
||||
{MTL::PixelFormatASTC_5x5_LDR, 0}, // ASTC_2D_5X5_UNORM
|
||||
{MTL::PixelFormatASTC_5x5_sRGB, 0}, // ASTC_2D_5X5_SRGB
|
||||
{MTL::PixelFormatASTC_10x8_LDR, 0}, // ASTC_2D_10X8_UNORM
|
||||
{MTL::PixelFormatASTC_10x8_sRGB, 0}, // ASTC_2D_10X8_SRGB
|
||||
{MTL::PixelFormatASTC_6x6_LDR, 0}, // ASTC_2D_6X6_UNORM
|
||||
{MTL::PixelFormatASTC_6x6_sRGB, 0}, // ASTC_2D_6X6_SRGB
|
||||
{MTL::PixelFormatASTC_10x6_LDR, 0}, // ASTC_2D_10X6_UNORM
|
||||
{MTL::PixelFormatASTC_10x6_sRGB, 0}, // ASTC_2D_10X6_SRGB
|
||||
{MTL::PixelFormatASTC_10x5_LDR, 0}, // ASTC_2D_10X5_UNORM
|
||||
{MTL::PixelFormatASTC_10x5_sRGB, 0}, // ASTC_2D_10X5_SRGB
|
||||
{MTL::PixelFormatASTC_10x10_LDR, 0}, // ASTC_2D_10X10_UNORM
|
||||
{MTL::PixelFormatASTC_10x10_sRGB, 0}, // ASTC_2D_10X10_SRGB
|
||||
{MTL::PixelFormatASTC_12x10_LDR, 0}, // ASTC_2D_12X10_UNORM
|
||||
{MTL::PixelFormatASTC_12x10_sRGB, 0}, // ASTC_2D_12X10_SRGB
|
||||
{MTL::PixelFormatASTC_12x12_LDR, 0}, // ASTC_2D_12X12_UNORM
|
||||
{MTL::PixelFormatASTC_12x12_sRGB, 0}, // ASTC_2D_12X12_SRGB
|
||||
{MTL::PixelFormatASTC_8x6_LDR, 0}, // ASTC_2D_8X6_UNORM
|
||||
{MTL::PixelFormatASTC_8x6_sRGB, 0}, // ASTC_2D_8X6_SRGB
|
||||
{MTL::PixelFormatASTC_6x5_LDR, 0}, // ASTC_2D_6X5_UNORM
|
||||
{MTL::PixelFormatASTC_6x5_sRGB, 0}, // ASTC_2D_6X5_SRGB
|
||||
{MTL::PixelFormatASTC_4x4_sRGB, 16, {4, 4}, false}, // ASTC_2D_4X4_SRGB
|
||||
{MTL::PixelFormatASTC_8x8_sRGB, 0, {0, 0}, false}, // ASTC_2D_8X8_SRGB TODO
|
||||
{MTL::PixelFormatASTC_8x5_sRGB, 0, {0, 0}, false}, // ASTC_2D_8X5_SRGB TODO
|
||||
{MTL::PixelFormatASTC_5x4_sRGB, 0, {0, 0}, false}, // ASTC_2D_5X4_SRGB TODO
|
||||
{MTL::PixelFormatASTC_5x5_LDR, 0, {0, 0}, false}, // ASTC_2D_5X5_UNORM TODO
|
||||
{MTL::PixelFormatASTC_5x5_sRGB, 0, {0, 0}, false}, // ASTC_2D_5X5_SRGB TODO
|
||||
{MTL::PixelFormatASTC_10x8_LDR, 0, {0, 0}, false}, // ASTC_2D_10X8_UNORM TODO
|
||||
{MTL::PixelFormatASTC_10x8_sRGB, 0, {0, 0}, false}, // ASTC_2D_10X8_SRGB TODO
|
||||
{MTL::PixelFormatASTC_6x6_LDR, 0, {0, 0}, false}, // ASTC_2D_6X6_UNORM TODO
|
||||
{MTL::PixelFormatASTC_6x6_sRGB, 0, {0, 0}, false}, // ASTC_2D_6X6_SRGB TODO
|
||||
{MTL::PixelFormatASTC_10x6_LDR, 0, {0, 0}, false}, // ASTC_2D_10X6_UNORM TODO
|
||||
{MTL::PixelFormatASTC_10x6_sRGB, 0, {0, 0}, false}, // ASTC_2D_10X6_SRGB TODO
|
||||
{MTL::PixelFormatASTC_10x5_LDR, 0, {0, 0}, false}, // ASTC_2D_10X5_UNORM TODO
|
||||
{MTL::PixelFormatASTC_10x5_sRGB, 0, {0, 0}, false}, // ASTC_2D_10X5_SRGB TODO
|
||||
{MTL::PixelFormatASTC_10x10_LDR, 0, {0, 0}, false}, // ASTC_2D_10X10_UNORM TODO
|
||||
{MTL::PixelFormatASTC_10x10_sRGB, 0, {0, 0}, false}, // ASTC_2D_10X10_SRGB TODO
|
||||
{MTL::PixelFormatASTC_12x10_LDR, 0, {0, 0}, false}, // ASTC_2D_12X10_UNORM TODO
|
||||
{MTL::PixelFormatASTC_12x10_sRGB, 0, {0, 0}, false}, // ASTC_2D_12X10_SRGB TODO
|
||||
{MTL::PixelFormatASTC_12x12_LDR, 0, {0, 0}, false}, // ASTC_2D_12X12_UNORM TODO
|
||||
{MTL::PixelFormatASTC_12x12_sRGB, 0, {0, 0}, false}, // ASTC_2D_12X12_SRGB TODO
|
||||
{MTL::PixelFormatASTC_8x6_LDR, 0, {0, 0}, false}, // ASTC_2D_8X6_UNORM TODO
|
||||
{MTL::PixelFormatASTC_8x6_sRGB, 0, {0, 0}, false}, // ASTC_2D_8X6_SRGB TODO
|
||||
{MTL::PixelFormatASTC_6x5_LDR, 0, {0, 0}, false}, // ASTC_2D_6X5_UNORM TODO
|
||||
{MTL::PixelFormatASTC_6x5_sRGB, 0, {0, 0}, false}, // ASTC_2D_6X5_SRGB TODO
|
||||
{MTL::PixelFormatInvalid, 0}, // E5B9G9R9_FLOAT
|
||||
{MTL::PixelFormatDepth32Float, 0}, // D32_FLOAT
|
||||
{MTL::PixelFormatDepth16Unorm, 0}, // D16_UNORM
|
||||
|
|
|
@ -17,7 +17,10 @@ namespace Metal {
|
|||
namespace {
|
||||
|
||||
MTL::Buffer* CreatePrivateBuffer(const Device& device, size_t size) {
|
||||
return device.GetDevice()->newBuffer(size, MTL::ResourceStorageModePrivate);
|
||||
MTL::Buffer* buffer = device.GetDevice()->newBuffer(size, MTL::ResourceStorageModePrivate);
|
||||
buffer->setLabel(NS::String::string("Buffer cache buffer", NS::ASCIIStringEncoding));
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
} // Anonymous namespace
|
||||
|
@ -80,6 +83,8 @@ void BufferCacheRuntime::CopyBuffer(MTL::Buffer* dst_buffer, MTL::Buffer* src_bu
|
|||
}
|
||||
|
||||
void BufferCacheRuntime::ClearBuffer(MTL::Buffer* dest_buffer, u32 offset, size_t size, u32 value) {
|
||||
LOG_DEBUG(Render_Metal, "called (buffer: {}, offset: {}, size: {}, value: {})", (void*)dest_buffer,
|
||||
offset, size, value);
|
||||
// TODO: clear buffer
|
||||
}
|
||||
|
||||
|
@ -91,6 +96,7 @@ void BufferCacheRuntime::BindIndexBuffer(PrimitiveTopology topology, IndexFormat
|
|||
}
|
||||
|
||||
void BufferCacheRuntime::BindQuadIndexBuffer(PrimitiveTopology topology, u32 first, u32 count) {
|
||||
LOG_DEBUG(Render_Metal, "called");
|
||||
// TODO: bind quad index buffer
|
||||
}
|
||||
|
||||
|
@ -122,7 +128,7 @@ void BufferCacheRuntime::ReserveNullBuffer() {
|
|||
}
|
||||
|
||||
MTL::Buffer* BufferCacheRuntime::CreateNullBuffer() {
|
||||
return CreatePrivateBuffer(device, NULL_BUFFER_SIZE * 2);
|
||||
return CreatePrivateBuffer(device, NULL_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
} // namespace Metal
|
||||
|
|
|
@ -405,51 +405,6 @@ std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline(
|
|||
previous_stage = &program;
|
||||
}
|
||||
|
||||
// HACK: create hardcoded shaders
|
||||
/*
|
||||
MTL::CompileOptions* compile_options = MTL::CompileOptions::alloc()->init();
|
||||
NS::Error* error = nullptr;
|
||||
MTL::Library* library = device.GetDevice()->newLibrary(NS::String::string(
|
||||
R"(
|
||||
#include <metal_stdlib>
|
||||
using namespace metal;
|
||||
|
||||
constant float2 positions[] = {
|
||||
float2(-1.0, -3.0),
|
||||
float2(-1.0, 1.0),
|
||||
float2( 3.0, 1.0),
|
||||
};
|
||||
|
||||
struct VertexOut {
|
||||
float4 position [[position]];
|
||||
float2 texCoord;
|
||||
};
|
||||
|
||||
vertex VertexOut vertexMain(uint vid [[vertex_id]]) {
|
||||
VertexOut out;
|
||||
out.position = float4(positions[vid], 0.0, 1.0);
|
||||
out.texCoord = positions[vid] * 0.5 + 0.5;
|
||||
out.texCoord.y = 1.0 - out.texCoord.y;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
fragment float4 fragmentMain(VertexOut in [[stage_in]], texture2d<float> tex [[texture(0)]],
|
||||
sampler samplr [[sampler(0)]]) { return tex.sample(samplr, in.texCoord);
|
||||
}
|
||||
)",
|
||||
NS::ASCIIStringEncoding),
|
||||
compile_options, &error);
|
||||
if (error) {
|
||||
LOG_ERROR(Render_Metal, "failed to create library: {}",
|
||||
error->description()->cString(NS::ASCIIStringEncoding));
|
||||
}
|
||||
|
||||
functions[0] = library->newFunction(NS::String::string("vertexMain", NS::ASCIIStringEncoding));
|
||||
functions[4] =
|
||||
library->newFunction(NS::String::string("fragmentMain", NS::ASCIIStringEncoding));
|
||||
*/
|
||||
|
||||
return std::make_unique<GraphicsPipeline>(device, command_recorder, key, buffer_cache,
|
||||
texture_cache, &shader_notify, functions, infos);
|
||||
} catch (const std::exception& e) {
|
||||
|
|
|
@ -127,6 +127,7 @@ void RasterizerMetal::Clear(u32 layer_count) {
|
|||
return;
|
||||
}
|
||||
|
||||
// TODO: clear
|
||||
command_recorder.BeginOrContinueRenderPass(framebuffer->GetHandle());
|
||||
}
|
||||
|
||||
|
@ -146,6 +147,7 @@ void RasterizerMetal::Query(GPUVAddr gpu_addr, VideoCommon::QueryType type,
|
|||
if (!gpu_memory) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (True(flags & VideoCommon::QueryPropertiesFlags::HasTimeout)) {
|
||||
u64 ticks = gpu.GetTicks();
|
||||
gpu_memory->Write<u64>(gpu_addr + 8, ticks);
|
||||
|
@ -365,8 +367,6 @@ void RasterizerMetal::LoadDiskResources(u64 title_id, std::stop_token stop_loadi
|
|||
}
|
||||
|
||||
void RasterizerMetal::InitializeChannel(Tegra::Control::ChannelState& channel) {
|
||||
LOG_DEBUG(Render_Metal, "called");
|
||||
|
||||
CreateChannel(channel);
|
||||
buffer_cache.CreateChannel(channel);
|
||||
texture_cache.CreateChannel(channel);
|
||||
|
@ -374,8 +374,6 @@ void RasterizerMetal::InitializeChannel(Tegra::Control::ChannelState& channel) {
|
|||
}
|
||||
|
||||
void RasterizerMetal::BindChannel(Tegra::Control::ChannelState& channel) {
|
||||
LOG_DEBUG(Render_Metal, "called");
|
||||
|
||||
BindToChannel(channel.bind_id);
|
||||
buffer_cache.BindToChannel(channel.bind_id);
|
||||
texture_cache.BindToChannel(channel.bind_id);
|
||||
|
@ -383,8 +381,6 @@ void RasterizerMetal::BindChannel(Tegra::Control::ChannelState& channel) {
|
|||
}
|
||||
|
||||
void RasterizerMetal::ReleaseChannel(s32 channel_id) {
|
||||
LOG_DEBUG(Render_Metal, "called");
|
||||
|
||||
EraseChannel(channel_id);
|
||||
buffer_cache.EraseChannel(channel_id);
|
||||
texture_cache.EraseChannel(channel_id);
|
||||
|
|
|
@ -38,13 +38,14 @@ StagingBufferRef StagingBuffer::Ref() const noexcept {
|
|||
}
|
||||
|
||||
// TODO: use the _MiB suffix
|
||||
constexpr size_t STREAM_BUFFER_SIZE = 128 * 1024 * 1024; // 128_MiB;
|
||||
constexpr size_t STREAM_BUFFER_SIZE = 128 * 1024 * 1024;//128_MiB;
|
||||
constexpr size_t REGION_SIZE = STREAM_BUFFER_SIZE / StagingBufferPool::NUM_SYNCS;
|
||||
|
||||
StagingBufferPool::StagingBufferPool(const Device& device_, CommandRecorder& command_recorder_)
|
||||
: device{device_}, command_recorder{command_recorder_} {
|
||||
stream_buffer =
|
||||
device.GetDevice()->newBuffer(STREAM_BUFFER_SIZE, MTL::ResourceStorageModeShared);
|
||||
stream_buffer->setLabel(NS::String::string("Stream buffer", NS::ASCIIStringEncoding));
|
||||
}
|
||||
|
||||
StagingBufferPool::~StagingBufferPool() = default;
|
||||
|
@ -106,6 +107,7 @@ StagingBufferRef StagingBufferPool::CreateStagingBuffer(size_t size, MemoryUsage
|
|||
bool deferred) {
|
||||
const u32 log2 = Common::Log2Ceil64(size);
|
||||
MTL::Buffer* buffer = device.GetDevice()->newBuffer(size, MTL::ResourceStorageModeShared);
|
||||
buffer->setLabel(NS::String::string("Staging buffer", NS::ASCIIStringEncoding));
|
||||
// TODO: check if the mapped span is correct
|
||||
std::span<u8> mapped_span(static_cast<u8*>(buffer->contents()), size);
|
||||
auto& entry = GetCache(usage)[log2].entries.emplace_back(buffer, mapped_span);
|
||||
|
|
|
@ -59,13 +59,19 @@ void TextureCacheRuntime::FreeDeferredStagingBuffer(StagingBufferRef& ref) {
|
|||
Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info, GPUVAddr gpu_addr_,
|
||||
VAddr cpu_addr_)
|
||||
: VideoCommon::ImageBase(info, gpu_addr_, cpu_addr_), runtime{&runtime_} {
|
||||
const auto& pixel_format_info = MaxwellToMTL::GetPixelFormatInfo(info.format);
|
||||
|
||||
MTL::TextureDescriptor* texture_descriptor = MTL::TextureDescriptor::alloc()->init();
|
||||
texture_descriptor->setPixelFormat(MaxwellToMTL::GetPixelFormatInfo(info.format).pixel_format);
|
||||
texture_descriptor->setPixelFormat(pixel_format_info.pixel_format);
|
||||
texture_descriptor->setWidth(info.size.width);
|
||||
texture_descriptor->setHeight(info.size.height);
|
||||
texture_descriptor->setDepth(info.size.depth);
|
||||
texture_descriptor->setUsage(MTL::TextureUsageShaderRead | MTL::TextureUsageRenderTarget);
|
||||
// TODO: set other parameters
|
||||
|
||||
MTL::TextureUsage usage = MTL::TextureUsageShaderRead | MTL::TextureUsageShaderWrite;
|
||||
if (pixel_format_info.can_be_render_target) {
|
||||
usage |= MTL::TextureUsageRenderTarget;
|
||||
}
|
||||
texture_descriptor->setUsage(usage);
|
||||
|
||||
texture = runtime->device.GetDevice()->newTexture(texture_descriptor);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ void RendererMetal::Composite(std::span<const Tegra::FramebufferConfig> framebuf
|
|||
// Ask the swap chain to get next drawable
|
||||
swap_chain.AcquireNextDrawable();
|
||||
|
||||
// TODO: copy the framebuffer to the drawable texture instead of this dummy render pass
|
||||
// Blit the framebuffer using a render pass
|
||||
MTL::RenderPassDescriptor* render_pass_descriptor = MTL::RenderPassDescriptor::alloc()->init();
|
||||
render_pass_descriptor->colorAttachments()->object(0)->setLoadAction(MTL::LoadActionDontCare);
|
||||
render_pass_descriptor->colorAttachments()->object(0)->setStoreAction(MTL::StoreActionStore);
|
||||
|
|
Loading…
Reference in a new issue