mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-22 14:52:45 +01:00
fix: constant buffers not getting bound
This commit is contained in:
parent
dac285f6d9
commit
1d39266956
6 changed files with 15 additions and 7 deletions
|
@ -1,7 +1,6 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 suyu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 suyu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#include "shader_recompiler/backend/msl/emit_msl_instructions.h"
|
#include "shader_recompiler/backend/msl/emit_msl_instructions.h"
|
||||||
|
|
|
@ -342,7 +342,7 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
|
||||||
|
|
||||||
void EmitContext::DefineInputs(Bindings& bindings) {
|
void EmitContext::DefineInputs(Bindings& bindings) {
|
||||||
// Constant buffers
|
// Constant buffers
|
||||||
bindings.uniform_buffer = 0;
|
bindings.uniform_buffer = 0; // HACK
|
||||||
for (const auto& desc : info.constant_buffer_descriptors) {
|
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_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};
|
const u32 cbuf_binding_size{info.uses_global_memory ? 0x1000U : cbuf_used_size};
|
||||||
|
@ -363,7 +363,7 @@ void EmitContext::DefineInputs(Bindings& bindings) {
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
// Storage space buffers
|
// Storage space buffers
|
||||||
bindings.uniform_buffer = 15;
|
bindings.uniform_buffer = 8; // HACK
|
||||||
u32 index{};
|
u32 index{};
|
||||||
for (const auto& desc : info.storage_buffers_descriptors) {
|
for (const auto& desc : info.storage_buffers_descriptors) {
|
||||||
if (has_at_least_one_input)
|
if (has_at_least_one_input)
|
||||||
|
|
|
@ -102,8 +102,10 @@ void BufferCacheRuntime::BindVertexBuffer(u32 index, MTL::Buffer* buffer, u32 of
|
||||||
void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings) {
|
void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings) {
|
||||||
for (u32 index = 0; index < bindings.buffers.size(); ++index) {
|
for (u32 index = 0; index < bindings.buffers.size(); ++index) {
|
||||||
auto handle = bindings.buffers[index]->Handle();
|
auto handle = bindings.buffers[index]->Handle();
|
||||||
// TODO: set stride?
|
if (handle) {
|
||||||
BindVertexBuffer(index, handle, bindings.offsets[index], bindings.sizes[index], 0);
|
// TODO: set stride?
|
||||||
|
BindVertexBuffer(index, handle, bindings.offsets[index], bindings.sizes[index], 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ public:
|
||||||
|
|
||||||
void BindStorageBuffer(size_t stage, u32 binding_index, MTL::Buffer* buffer, u32 offset,
|
void BindStorageBuffer(size_t stage, u32 binding_index, MTL::Buffer* buffer, u32 offset,
|
||||||
u32 size, [[maybe_unused]] bool is_written) {
|
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
|
// TODO: implement
|
||||||
|
|
|
@ -46,6 +46,8 @@ GraphicsPipeline::GraphicsPipeline(const Device& device_, CommandRecorder& comma
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
stage_infos[stage] = *info;
|
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();
|
Validate();
|
||||||
// TODO: is the framebuffer available by this time?
|
// 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& view_index{all_views[stage].view_index};
|
||||||
size_t& sampler_index{all_samplers[stage].sampler_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);
|
buffer_cache.UnbindGraphicsStorageBuffers(stage);
|
||||||
size_t ssbo_index{};
|
size_t ssbo_index{};
|
||||||
for (const auto& desc : info.storage_buffers_descriptors) {
|
for (const auto& desc : info.storage_buffers_descriptors) {
|
||||||
|
|
|
@ -114,7 +114,8 @@ private:
|
||||||
std::array<MTL::Function*, NUM_STAGES> functions;
|
std::array<MTL::Function*, NUM_STAGES> functions;
|
||||||
|
|
||||||
std::array<Shader::Info, NUM_STAGES> stage_infos;
|
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{};
|
// u32 num_textures{};
|
||||||
|
|
||||||
MTL::RenderPipelineState* pipeline_state{nullptr};
|
MTL::RenderPipelineState* pipeline_state{nullptr};
|
||||||
|
|
Loading…
Reference in a new issue