metal: add basic compute pipeline

This commit is contained in:
Samuliak 2024-04-07 15:51:11 +02:00
parent a5e7672de5
commit 081ad83490
No known key found for this signature in database
3 changed files with 94 additions and 0 deletions

View file

@ -378,6 +378,7 @@ if (APPLE)
renderer_metal/mtl_buffer_cache.cpp
renderer_metal/mtl_buffer_cache_base.cpp
renderer_metal/mtl_command_recorder.cpp
renderer_metal/mtl_compute_pipeline.cpp
renderer_metal/mtl_device.cpp
renderer_metal/mtl_graphics_pipeline.cpp
renderer_metal/mtl_rasterizer.cpp

View file

@ -0,0 +1,44 @@
// SPDX-FileCopyrightText: Copyright 2024 suyu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>
#include <vector>
#include <boost/container/small_vector.hpp>
#include "video_core/buffer_cache/buffer_cache_base.h"
#include "video_core/renderer_metal/mtl_compute_pipeline.h"
#include "video_core/renderer_metal/mtl_device.h"
#include "video_core/shader_notify.h"
#include "video_core/texture_cache/texture_cache_base.h"
namespace Metal {
ComputePipeline::ComputePipeline(const Device& device_, VideoCore::ShaderNotify* shader_notify,
const Shader::Info& info_, MTL::Function* function_)
: device{device_}, info{info_}, function{function_} {
if (shader_notify) {
shader_notify->MarkShaderBuilding();
}
MTL::ComputePipelineDescriptor* pipeline_descriptor =
MTL::ComputePipelineDescriptor::alloc()->init();
pipeline_descriptor->setComputeFunction(function);
// TODO: set other properties
NS::Error* error = nullptr;
pipeline_state =
device.GetDevice()->newComputePipelineState(pipeline_descriptor, 0, nullptr, &error);
if (error) {
LOG_ERROR(Render_Metal, "failed to create compute pipeline: {}",
error->description()->cString(NS::ASCIIStringEncoding));
}
}
void ComputePipeline::Configure(Tegra::Engines::KeplerCompute& kepler_compute,
Tegra::MemoryManager& gpu_memory, CommandRecorder& scheduler,
BufferCache& buffer_cache, TextureCache& texture_cache) {
// TODO: bind resources
}
} // namespace Metal

View file

@ -0,0 +1,49 @@
// SPDX-FileCopyrightText: Copyright 2024 suyu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <atomic>
#include <condition_variable>
#include <mutex>
#include "common/common_types.h"
#include "common/thread_worker.h"
#include "shader_recompiler/shader_info.h"
#include "video_core/renderer_metal/mtl_buffer_cache.h"
#include "video_core/renderer_metal/mtl_texture_cache.h"
namespace VideoCore {
class ShaderNotify;
}
namespace Metal {
class Device;
class PipelineStatistics;
class Scheduler;
class ComputePipeline {
public:
explicit ComputePipeline(const Device& device_, VideoCore::ShaderNotify* shader_notify,
const Shader::Info& info_, MTL::Function* function_);
ComputePipeline& operator=(ComputePipeline&&) noexcept = delete;
ComputePipeline(ComputePipeline&&) noexcept = delete;
ComputePipeline& operator=(const ComputePipeline&) = delete;
ComputePipeline(const ComputePipeline&) = delete;
void Configure(Tegra::Engines::KeplerCompute& kepler_compute, Tegra::MemoryManager& gpu_memory,
CommandRecorder& scheduler, BufferCache& buffer_cache,
TextureCache& texture_cache);
private:
const Device& device;
Shader::Info info;
MTL::Function* function;
MTL::ComputePipelineState* pipeline_state;
};
} // namespace Metal