fix: constant buffers not getting bound

This commit is contained in:
Samuliak 2024-10-05 17:02:46 +02:00
parent dac285f6d9
commit 1d39266956
No known key found for this signature in database
6 changed files with 15 additions and 7 deletions

View file

@ -1,7 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2024 suyu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <iostream>
#include <string_view>
#include "shader_recompiler/backend/msl/emit_msl_instructions.h"

View file

@ -342,7 +342,7 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
void EmitContext::DefineInputs(Bindings& bindings) {
// Constant buffers
bindings.uniform_buffer = 0;
bindings.uniform_buffer = 0; // HACK
for (const auto& desc : info.constant_buffer_descriptors) {
const u32 cbuf_used_size{Common::DivCeil(info.constant_buffer_used_sizes[desc.index], 16U)};
const u32 cbuf_binding_size{info.uses_global_memory ? 0x1000U : cbuf_used_size};
@ -363,7 +363,7 @@ void EmitContext::DefineInputs(Bindings& bindings) {
// TODO
// Storage space buffers
bindings.uniform_buffer = 15;
bindings.uniform_buffer = 8; // HACK
u32 index{};
for (const auto& desc : info.storage_buffers_descriptors) {
if (has_at_least_one_input)

View file

@ -102,8 +102,10 @@ void BufferCacheRuntime::BindVertexBuffer(u32 index, MTL::Buffer* buffer, u32 of
void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings) {
for (u32 index = 0; index < bindings.buffers.size(); ++index) {
auto handle = bindings.buffers[index]->Handle();
// TODO: set stride?
BindVertexBuffer(index, handle, bindings.offsets[index], bindings.sizes[index], 0);
if (handle) {
// TODO: set stride?
BindVertexBuffer(index, handle, bindings.offsets[index], bindings.sizes[index], 0);
}
}
}

View file

@ -138,7 +138,7 @@ public:
void BindStorageBuffer(size_t stage, u32 binding_index, MTL::Buffer* buffer, u32 offset,
u32 size, [[maybe_unused]] bool is_written) {
BindBuffer(stage, binding_index, buffer, offset, size);
BindBuffer(stage, binding_index + 8, buffer, offset, size); // HACK: offset by 8
}
// TODO: implement

View file

@ -46,6 +46,8 @@ GraphicsPipeline::GraphicsPipeline(const Device& device_, CommandRecorder& comma
continue;
}
stage_infos[stage] = *info;
enabled_uniform_buffer_masks[stage] = info->constant_buffer_mask;
std::ranges::copy(info->constant_buffer_used_sizes, uniform_buffer_sizes[stage].begin());
}
Validate();
// TODO: is the framebuffer available by this time?
@ -81,6 +83,10 @@ void GraphicsPipeline::Configure(bool is_indexed) {
size_t& view_index{all_views[stage].view_index};
size_t& sampler_index{all_samplers[stage].sampler_index};
texture_cache.SynchronizeGraphicsDescriptors();
buffer_cache.SetUniformBuffersState(enabled_uniform_buffer_masks, &uniform_buffer_sizes);
buffer_cache.UnbindGraphicsStorageBuffers(stage);
size_t ssbo_index{};
for (const auto& desc : info.storage_buffers_descriptors) {

View file

@ -114,7 +114,8 @@ private:
std::array<MTL::Function*, NUM_STAGES> functions;
std::array<Shader::Info, NUM_STAGES> stage_infos;
// VideoCommon::UniformBufferSizes uniform_buffer_sizes{};
std::array<u32, 5> enabled_uniform_buffer_masks{};
VideoCommon::UniformBufferSizes uniform_buffer_sizes{};
// u32 num_textures{};
MTL::RenderPipelineState* pipeline_state{nullptr};