mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-22 14:52:45 +01:00
metal: bind pipeline and draw for the first time
This commit is contained in:
parent
4d700ac01c
commit
90b8671ddb
6 changed files with 37 additions and 16 deletions
|
@ -81,10 +81,11 @@ void BufferCacheRuntime::Finish() {}
|
|||
void BufferCacheRuntime::CopyBuffer(MTL::Buffer* dst_buffer, MTL::Buffer* src_buffer,
|
||||
std::span<const VideoCommon::BufferCopy> copies, bool barrier,
|
||||
bool can_reorder_upload) {
|
||||
for (const VideoCommon::BufferCopy& copy : copies) {
|
||||
command_recorder.GetBlitCommandEncoder()->copyFromBuffer(
|
||||
src_buffer, copy.src_offset, dst_buffer, copy.dst_offset, copy.size);
|
||||
}
|
||||
// HACK: needs to be commented out, since it iterrupts render pass
|
||||
// for (const VideoCommon::BufferCopy& copy : copies) {
|
||||
// command_recorder.GetBlitCommandEncoder()->copyFromBuffer(
|
||||
// src_buffer, copy.src_offset, dst_buffer, copy.dst_offset, copy.size);
|
||||
// }
|
||||
}
|
||||
|
||||
void BufferCacheRuntime::ClearBuffer(MTL::Buffer* dest_buffer, u32 offset, size_t size, u32 value) {
|
||||
|
|
|
@ -4,18 +4,16 @@
|
|||
#include "video_core/renderer_metal/mtl_command_recorder.h"
|
||||
#include "video_core/renderer_metal/mtl_device.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace Metal {
|
||||
|
||||
CommandRecorder::CommandRecorder(const Device& device_) : device(device_) {}
|
||||
|
||||
CommandRecorder::~CommandRecorder() = default;
|
||||
|
||||
void CommandRecorder::BeginRenderPass(MTL::RenderPassDescriptor* render_pass_descriptor) {
|
||||
void CommandRecorder::BeginRenderPass(MTL::RenderPassDescriptor* render_pass) {
|
||||
RequireCommandBuffer();
|
||||
EndEncoding();
|
||||
encoder = command_buffer->renderCommandEncoder(render_pass_descriptor);
|
||||
encoder = command_buffer->renderCommandEncoder(render_pass);
|
||||
encoder_type = EncoderType::Render;
|
||||
}
|
||||
|
||||
|
@ -41,7 +39,7 @@ void CommandRecorder::EndEncoding() {
|
|||
if (encoder) {
|
||||
encoder->endEncoding();
|
||||
//[encoder release];
|
||||
encoder = nil;
|
||||
encoder = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +53,7 @@ void CommandRecorder::Submit() {
|
|||
EndEncoding();
|
||||
command_buffer->commit();
|
||||
//[command_buffer release];
|
||||
command_buffer = nil;
|
||||
command_buffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
CommandRecorder(const Device& device_);
|
||||
~CommandRecorder();
|
||||
|
||||
void BeginRenderPass(MTL::RenderPassDescriptor* render_pass_descriptor);
|
||||
void BeginRenderPass(MTL::RenderPassDescriptor* render_pass);
|
||||
|
||||
void CheckIfRenderPassIsActive() {
|
||||
if (!encoder || encoder_type != EncoderType::Render) {
|
||||
|
|
|
@ -103,6 +103,10 @@ public:
|
|||
gpu_memory = gpu_memory_;
|
||||
}
|
||||
|
||||
MTL::RenderPipelineState* GetPipelineState() const noexcept {
|
||||
return pipeline_state;
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename Spec>
|
||||
void ConfigureImpl(bool is_indexed);
|
||||
|
|
|
@ -157,6 +157,7 @@ GraphicsPipeline* PipelineCache::CurrentGraphicsPipeline() {
|
|||
return BuiltPipeline(current_pipeline);
|
||||
}
|
||||
}
|
||||
|
||||
return CurrentGraphicsPipelineSlowPath();
|
||||
}
|
||||
|
||||
|
@ -263,7 +264,7 @@ std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline(
|
|||
library->newFunction(NS::String::string("fragmentMain", NS::ASCIIStringEncoding));
|
||||
|
||||
// HACK: dummy info
|
||||
std::array<const Shader::Info*, VideoCommon::NUM_STAGES> infos;
|
||||
std::array<const Shader::Info*, VideoCommon::NUM_STAGES> infos = {nullptr};
|
||||
infos[0] = new Shader::Info{};
|
||||
infos[1] = new Shader::Info{};
|
||||
|
||||
|
|
|
@ -41,6 +41,24 @@ RasterizerMetal::RasterizerMetal(Tegra::GPU& gpu_,
|
|||
RasterizerMetal::~RasterizerMetal() = default;
|
||||
|
||||
void RasterizerMetal::Draw(bool is_indexed, u32 instance_count) {
|
||||
LOG_DEBUG(Render_Metal, "called");
|
||||
|
||||
// Bind the current graphics pipeline
|
||||
GraphicsPipeline* const pipeline{pipeline_cache.CurrentGraphicsPipeline()};
|
||||
if (!pipeline) {
|
||||
return;
|
||||
}
|
||||
command_recorder.GetRenderCommandEncoder()->setRenderPipelineState(
|
||||
pipeline->GetPipelineState());
|
||||
|
||||
// HACK: test is buffers are being correctly created
|
||||
buffer_cache.UpdateGraphicsBuffers(is_indexed);
|
||||
buffer_cache.BindHostGeometryBuffers(is_indexed);
|
||||
|
||||
// HACK: dummy draw call
|
||||
command_recorder.GetRenderCommandEncoder()->drawPrimitives(MTL::PrimitiveTypeTriangle,
|
||||
NS::UInteger(0), NS::UInteger(3));
|
||||
|
||||
// TODO: uncomment
|
||||
// command_recorder.CheckIfRenderPassIsActive();
|
||||
// const auto& draw_state = maxwell3d->draw_manager->GetDrawState();
|
||||
|
@ -62,10 +80,6 @@ void RasterizerMetal::Draw(bool is_indexed, u32 instance_count) {
|
|||
// cmdbuf.Draw(draw_params.num_vertices, draw_params.num_instances,
|
||||
// draw_params.base_vertex, draw_params.base_instance);
|
||||
}
|
||||
|
||||
// HACK: test is buffers are being correctly created
|
||||
buffer_cache.UpdateGraphicsBuffers(is_indexed);
|
||||
buffer_cache.BindHostGeometryBuffers(is_indexed);
|
||||
}
|
||||
|
||||
void RasterizerMetal::DrawTexture() {
|
||||
|
@ -246,6 +260,7 @@ void RasterizerMetal::InitializeChannel(Tegra::Control::ChannelState& channel) {
|
|||
CreateChannel(channel);
|
||||
buffer_cache.CreateChannel(channel);
|
||||
texture_cache.CreateChannel(channel);
|
||||
pipeline_cache.CreateChannel(channel);
|
||||
}
|
||||
|
||||
void RasterizerMetal::BindChannel(Tegra::Control::ChannelState& channel) {
|
||||
|
@ -254,6 +269,7 @@ void RasterizerMetal::BindChannel(Tegra::Control::ChannelState& channel) {
|
|||
BindToChannel(channel.bind_id);
|
||||
buffer_cache.BindToChannel(channel.bind_id);
|
||||
texture_cache.BindToChannel(channel.bind_id);
|
||||
pipeline_cache.BindToChannel(channel.bind_id);
|
||||
}
|
||||
|
||||
void RasterizerMetal::ReleaseChannel(s32 channel_id) {
|
||||
|
@ -262,6 +278,7 @@ void RasterizerMetal::ReleaseChannel(s32 channel_id) {
|
|||
EraseChannel(channel_id);
|
||||
buffer_cache.EraseChannel(channel_id);
|
||||
texture_cache.EraseChannel(channel_id);
|
||||
pipeline_cache.EraseChannel(channel_id);
|
||||
}
|
||||
|
||||
} // namespace Metal
|
||||
|
|
Loading…
Reference in a new issue