metal: configure pipeline before drawing

Cette révision appartient à :
Samuliak 2024-04-08 16:47:08 +02:00
Parent 22ec7e72f0
révision 3fa495840a
Signature inconnue de Forgejo
3 fichiers modifiés avec 11 ajouts et 33 suppressions

Voir le fichier

@ -53,22 +53,20 @@ GraphicsPipeline::GraphicsPipeline(const Device& device_, CommandRecorder& comma
return;
}
MakePipeline(framebuffer->GetHandle());
// configure_func = ConfigureFunc(functions, stage_infos);
}
template <typename Spec>
void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
// TODO: implement
}
void GraphicsPipeline::Configure(bool is_indexed) {
buffer_cache.UpdateGraphicsBuffers(is_indexed);
buffer_cache.BindHostGeometryBuffers(is_indexed);
void GraphicsPipeline::ConfigureDraw() {
Framebuffer* framebuffer = texture_cache.GetFramebuffer();
texture_cache.UpdateRenderTargets(true);
const Framebuffer* const framebuffer = texture_cache.GetFramebuffer();
if (!framebuffer) {
return;
}
// MTL::RenderPassDescriptor* render_pass = framebuffer->GetHandle();
command_recorder.BeginOrContinueRenderPass(framebuffer->GetHandle());
// TODO: bind resources
command_recorder.GetRenderCommandEncoder()->setRenderPipelineState(pipeline_state);
}
void GraphicsPipeline::MakePipeline(MTL::RenderPassDescriptor* render_pass) {

Voir le fichier

@ -80,9 +80,7 @@ public:
// TODO: implement
void AddTransition(GraphicsPipeline* transition) {}
void Configure(bool is_indexed) {
// configure_func(this, is_indexed);
}
void Configure(bool is_indexed);
[[nodiscard]] GraphicsPipeline* Next(const GraphicsPipelineCacheKey& current_key) noexcept {
// TODO: implement
@ -93,26 +91,12 @@ public:
return true;
}
template <typename Spec>
static auto MakeConfigureSpecFunc() {
return [](GraphicsPipeline* pl, bool is_indexed) { pl->ConfigureImpl<Spec>(is_indexed); };
}
void SetEngine(Tegra::Engines::Maxwell3D* maxwell3d_, Tegra::MemoryManager* gpu_memory_) {
maxwell3d = maxwell3d_;
gpu_memory = gpu_memory_;
}
MTL::RenderPipelineState* GetPipelineState() const noexcept {
return pipeline_state;
}
private:
template <typename Spec>
void ConfigureImpl(bool is_indexed);
void ConfigureDraw();
void MakePipeline(MTL::RenderPassDescriptor* render_pass);
void Validate();

Voir le fichier

@ -48,12 +48,7 @@ void RasterizerMetal::Draw(bool is_indexed, u32 instance_count) {
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);
pipeline->Configure(is_indexed);
// HACK: dummy draw call
command_recorder.GetRenderCommandEncoder()->drawPrimitives(MTL::PrimitiveTypeTriangle,
@ -95,7 +90,8 @@ void RasterizerMetal::Clear(u32 layer_count) {
return;
}
// Begin render pass
// TODO: track the textures used by render pass and only begin the render pass if their contents
// are needed Begin render pass
command_recorder.BeginOrContinueRenderPass(framebuffer->GetHandle());
}