mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-12-25 19:02:45 -06:00
fix: clang-format
This commit is contained in:
parent
1efdd483b7
commit
86b1f41de6
7 changed files with 133 additions and 128 deletions
|
@ -146,7 +146,8 @@ inline size_t GetTextureBytesPerRow(VideoCore::Surface::PixelFormat pixel_format
|
||||||
format_info.bytes_per_block;
|
format_info.bytes_per_block;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline MTL::VertexFormat VertexFormat(Maxwell::VertexAttribute::Type type, Maxwell::VertexAttribute::Size size) {
|
inline MTL::VertexFormat VertexFormat(Maxwell::VertexAttribute::Type type,
|
||||||
|
Maxwell::VertexAttribute::Size size) {
|
||||||
const MTL::VertexFormat format{([&]() {
|
const MTL::VertexFormat format{([&]() {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Maxwell::VertexAttribute::Type::UnusedEnumDoNotUseBecauseItWillGoAway:
|
case Maxwell::VertexAttribute::Type::UnusedEnumDoNotUseBecauseItWillGoAway:
|
||||||
|
|
|
@ -83,8 +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) {
|
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,
|
LOG_DEBUG(Render_Metal, "called (buffer: {}, offset: {}, size: {}, value: {})",
|
||||||
offset, size, value);
|
(void*)dest_buffer, offset, size, value);
|
||||||
// TODO: clear buffer
|
// TODO: clear buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,8 +110,7 @@ public:
|
||||||
|
|
||||||
void BindQuadIndexBuffer(PrimitiveTopology topology, u32 first, u32 count);
|
void BindQuadIndexBuffer(PrimitiveTopology topology, u32 first, u32 count);
|
||||||
|
|
||||||
void BindVertexBuffer(u32 index, MTL::Buffer* buffer, u32 offset, u32 size,
|
void BindVertexBuffer(u32 index, MTL::Buffer* buffer, u32 offset, u32 size, u32 stride);
|
||||||
u32 stride);
|
|
||||||
|
|
||||||
void BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings);
|
void BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings);
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,9 @@ struct BoundIndexBuffer {
|
||||||
size_t offset{0};
|
size_t offset{0};
|
||||||
MTL::IndexType index_type;
|
MTL::IndexType index_type;
|
||||||
size_t index_size;
|
size_t index_size;
|
||||||
//MTL::PrimitiveType primitive_topology;
|
// MTL::PrimitiveType primitive_topology;
|
||||||
//u32 num_indices;
|
// u32 num_indices;
|
||||||
//u32 base_vertex;
|
// u32 base_vertex;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RenderState {
|
struct RenderState {
|
||||||
|
|
|
@ -13,12 +13,12 @@
|
||||||
#include "common/bit_field.h"
|
#include "common/bit_field.h"
|
||||||
#include "video_core/buffer_cache/buffer_cache_base.h"
|
#include "video_core/buffer_cache/buffer_cache_base.h"
|
||||||
#include "video_core/engines/maxwell_3d.h"
|
#include "video_core/engines/maxwell_3d.h"
|
||||||
|
#include "video_core/renderer_metal/maxwell_to_mtl.h"
|
||||||
#include "video_core/renderer_metal/mtl_command_recorder.h"
|
#include "video_core/renderer_metal/mtl_command_recorder.h"
|
||||||
#include "video_core/renderer_metal/mtl_device.h"
|
#include "video_core/renderer_metal/mtl_device.h"
|
||||||
#include "video_core/shader_notify.h"
|
#include "video_core/shader_notify.h"
|
||||||
#include "video_core/texture_cache/texture_cache.h"
|
#include "video_core/texture_cache/texture_cache.h"
|
||||||
#include "video_core/texture_cache/texture_cache_base.h"
|
#include "video_core/texture_cache/texture_cache_base.h"
|
||||||
#include "video_core/renderer_metal/maxwell_to_mtl.h"
|
|
||||||
|
|
||||||
namespace Metal {
|
namespace Metal {
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -211,8 +211,7 @@ void GraphicsPipeline::MakePipeline(MTL::RenderPassDescriptor* render_pass) {
|
||||||
const auto& regs{maxwell3d->regs};
|
const auto& regs{maxwell3d->regs};
|
||||||
|
|
||||||
// Shader stages
|
// Shader stages
|
||||||
MTL::RenderPipelineDescriptor* desc =
|
MTL::RenderPipelineDescriptor* desc = MTL::RenderPipelineDescriptor::alloc()->init();
|
||||||
MTL::RenderPipelineDescriptor::alloc()->init();
|
|
||||||
desc->setVertexFunction(functions[0]);
|
desc->setVertexFunction(functions[0]);
|
||||||
desc->setFragmentFunction(functions[4]);
|
desc->setFragmentFunction(functions[4]);
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,8 @@ RasterizerMetal::RasterizerMetal(Tegra::GPU& gpu_,
|
||||||
texture_cache_runtime(device, command_recorder, staging_buffer_pool),
|
texture_cache_runtime(device, command_recorder, staging_buffer_pool),
|
||||||
texture_cache(texture_cache_runtime, device_memory),
|
texture_cache(texture_cache_runtime, device_memory),
|
||||||
pipeline_cache(device_memory, device, command_recorder, buffer_cache, texture_cache,
|
pipeline_cache(device_memory, device, command_recorder, buffer_cache, texture_cache,
|
||||||
gpu.ShaderNotify()), accelerate_dma(buffer_cache) {}
|
gpu.ShaderNotify()),
|
||||||
|
accelerate_dma(buffer_cache) {}
|
||||||
RasterizerMetal::~RasterizerMetal() = default;
|
RasterizerMetal::~RasterizerMetal() = default;
|
||||||
|
|
||||||
void RasterizerMetal::Draw(bool is_indexed, u32 instance_count) {
|
void RasterizerMetal::Draw(bool is_indexed, u32 instance_count) {
|
||||||
|
@ -98,19 +99,24 @@ void RasterizerMetal::Draw(bool is_indexed, u32 instance_count) {
|
||||||
const DrawParams draw_params{MakeDrawParams(draw_state, instance_count, is_indexed)};
|
const DrawParams draw_params{MakeDrawParams(draw_state, instance_count, is_indexed)};
|
||||||
|
|
||||||
// TODO: get the primitive type
|
// TODO: get the primitive type
|
||||||
MTL::PrimitiveType primitiveType = MTL::PrimitiveTypeTriangle;//MaxwellToMTL::PrimitiveType(draw_state.topology);
|
MTL::PrimitiveType primitiveType =
|
||||||
|
MTL::PrimitiveTypeTriangle; // MaxwellToMTL::PrimitiveType(draw_state.topology);
|
||||||
|
|
||||||
if (is_indexed) {
|
if (is_indexed) {
|
||||||
auto& index_buffer = command_recorder.GetBoundIndexBuffer();
|
auto& index_buffer = command_recorder.GetBoundIndexBuffer();
|
||||||
size_t index_buffer_offset = index_buffer.offset + draw_params.first_index * index_buffer.index_size;
|
size_t index_buffer_offset =
|
||||||
|
index_buffer.offset + draw_params.first_index * index_buffer.index_size;
|
||||||
|
|
||||||
ASSERT(index_buffer_offset % 4 == 0);
|
ASSERT(index_buffer_offset % 4 == 0);
|
||||||
|
|
||||||
command_recorder.GetRenderCommandEncoder()->drawIndexedPrimitives(primitiveType, draw_params.num_vertices, index_buffer.index_type, index_buffer.buffer, index_buffer_offset, draw_params.num_instances,
|
command_recorder.GetRenderCommandEncoder()->drawIndexedPrimitives(
|
||||||
draw_params.base_vertex, draw_params.base_instance);
|
primitiveType, draw_params.num_vertices, index_buffer.index_type, index_buffer.buffer,
|
||||||
|
index_buffer_offset, draw_params.num_instances, draw_params.base_vertex,
|
||||||
|
draw_params.base_instance);
|
||||||
} else {
|
} else {
|
||||||
command_recorder.GetRenderCommandEncoder()->drawPrimitives(primitiveType,
|
command_recorder.GetRenderCommandEncoder()->drawPrimitives(
|
||||||
draw_params.base_vertex, draw_params.num_vertices, draw_params.num_instances, draw_params.base_instance);
|
primitiveType, draw_params.base_vertex, draw_params.num_vertices,
|
||||||
|
draw_params.num_instances, draw_params.base_instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,9 +187,9 @@ void RasterizerMetal::FlushRegion(DAddr addr, u64 size, VideoCommon::CacheType w
|
||||||
if ((True(which & VideoCommon::CacheType::BufferCache))) {
|
if ((True(which & VideoCommon::CacheType::BufferCache))) {
|
||||||
buffer_cache.DownloadMemory(addr, size);
|
buffer_cache.DownloadMemory(addr, size);
|
||||||
}
|
}
|
||||||
//if ((True(which & VideoCommon::CacheType::QueryCache))) {
|
// if ((True(which & VideoCommon::CacheType::QueryCache))) {
|
||||||
// query_cache.FlushRegion(addr, size);
|
// query_cache.FlushRegion(addr, size);
|
||||||
//}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RasterizerMetal::MustFlushRegion(DAddr addr, u64 size, VideoCommon::CacheType which) {
|
bool RasterizerMetal::MustFlushRegion(DAddr addr, u64 size, VideoCommon::CacheType which) {
|
||||||
|
@ -228,9 +234,9 @@ void RasterizerMetal::InvalidateRegion(DAddr addr, u64 size, VideoCommon::CacheT
|
||||||
if ((True(which & VideoCommon::CacheType::BufferCache))) {
|
if ((True(which & VideoCommon::CacheType::BufferCache))) {
|
||||||
buffer_cache.WriteMemory(addr, size);
|
buffer_cache.WriteMemory(addr, size);
|
||||||
}
|
}
|
||||||
//if ((True(which & VideoCommon::CacheType::QueryCache))) {
|
// if ((True(which & VideoCommon::CacheType::QueryCache))) {
|
||||||
// query_cache.InvalidateRegion(addr, size);
|
// query_cache.InvalidateRegion(addr, size);
|
||||||
//}
|
// }
|
||||||
if ((True(which & VideoCommon::CacheType::ShaderCache))) {
|
if ((True(which & VideoCommon::CacheType::ShaderCache))) {
|
||||||
pipeline_cache.InvalidateRegion(addr, size);
|
pipeline_cache.InvalidateRegion(addr, size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ StagingBuffer::StagingBuffer(MTL::Buffer* buffer_, std::span<u8> mapped_span_)
|
||||||
|
|
||||||
StagingBuffer::~StagingBuffer() {
|
StagingBuffer::~StagingBuffer() {
|
||||||
// TODO: uncomment
|
// TODO: uncomment
|
||||||
//buffer->release();
|
// buffer->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
StagingBufferRef StagingBuffer::Ref() const noexcept {
|
StagingBufferRef StagingBuffer::Ref() const noexcept {
|
||||||
|
@ -38,7 +38,7 @@ StagingBufferRef StagingBuffer::Ref() const noexcept {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use the _MiB suffix
|
// 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;
|
constexpr size_t REGION_SIZE = STREAM_BUFFER_SIZE / StagingBufferPool::NUM_SYNCS;
|
||||||
|
|
||||||
StagingBufferPool::StagingBufferPool(const Device& device_, CommandRecorder& command_recorder_)
|
StagingBufferPool::StagingBufferPool(const Device& device_, CommandRecorder& command_recorder_)
|
||||||
|
|
Loading…
Reference in a new issue