mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-22 06:42:46 +01:00
bind buffers correctly
This commit is contained in:
parent
c24e3c23ff
commit
dac285f6d9
5 changed files with 12 additions and 20 deletions
|
@ -342,6 +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;
|
||||||
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};
|
||||||
|
@ -362,6 +363,7 @@ void EmitContext::DefineInputs(Bindings& bindings) {
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
// Storage space buffers
|
// Storage space buffers
|
||||||
|
bindings.uniform_buffer = 15;
|
||||||
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)
|
||||||
|
|
|
@ -109,7 +109,7 @@ void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bi
|
||||||
|
|
||||||
void BufferCacheRuntime::BindBuffer(size_t stage, u32 binding_index, MTL::Buffer* buffer,
|
void BufferCacheRuntime::BindBuffer(size_t stage, u32 binding_index, MTL::Buffer* buffer,
|
||||||
u32 offset, u32 size) {
|
u32 offset, u32 size) {
|
||||||
command_recorder.SetBuffer(stage, buffer, binding_index, offset);
|
command_recorder.SetBuffer(stage, buffer, offset, binding_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferCacheRuntime::ReserveNullBuffer() {
|
void BufferCacheRuntime::ReserveNullBuffer() {
|
||||||
|
|
|
@ -124,6 +124,7 @@ public:
|
||||||
std::span<u8> BindMappedUniformBuffer(size_t stage, u32 binding_index, u32 size) {
|
std::span<u8> BindMappedUniformBuffer(size_t stage, u32 binding_index, u32 size) {
|
||||||
const StagingBufferRef ref = staging_pool.Request(size, MemoryUsage::Upload);
|
const StagingBufferRef ref = staging_pool.Request(size, MemoryUsage::Upload);
|
||||||
BindBuffer(stage, binding_index, ref.buffer, static_cast<u32>(ref.offset), size);
|
BindBuffer(stage, binding_index, ref.buffer, static_cast<u32>(ref.offset), size);
|
||||||
|
|
||||||
return ref.mapped_span;
|
return ref.mapped_span;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ void CommandRecorder::BeginOrContinueRenderPass(MTL::RenderPassDescriptor* rende
|
||||||
render_state.render_pass = render_pass;
|
render_state.render_pass = render_pass;
|
||||||
should_reset_bound_resources = true;
|
should_reset_bound_resources = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto bind_resources{[&](size_t stage) {
|
const auto bind_resources{[&](size_t stage) {
|
||||||
// Buffers
|
// Buffers
|
||||||
for (u8 i = 0; i < MAX_BUFFERS; i++) {
|
for (u8 i = 0; i < MAX_BUFFERS; i++) {
|
||||||
|
@ -28,17 +29,18 @@ void CommandRecorder::BeginOrContinueRenderPass(MTL::RenderPassDescriptor* rende
|
||||||
(bound_buffer.needs_update || should_reset_bound_resources)) {
|
(bound_buffer.needs_update || should_reset_bound_resources)) {
|
||||||
switch (stage) {
|
switch (stage) {
|
||||||
case 0:
|
case 0:
|
||||||
GetRenderCommandEncoderUnchecked()->setVertexBuffer(bound_buffer.buffer, i,
|
GetRenderCommandEncoderUnchecked()->setVertexBuffer(bound_buffer.buffer,
|
||||||
bound_buffer.offset);
|
bound_buffer.offset, i);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
GetRenderCommandEncoderUnchecked()->setFragmentBuffer(bound_buffer.buffer, i,
|
GetRenderCommandEncoderUnchecked()->setFragmentBuffer(bound_buffer.buffer,
|
||||||
bound_buffer.offset);
|
bound_buffer.offset, i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bound_buffer.needs_update = false;
|
bound_buffer.needs_update = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Textures
|
// Textures
|
||||||
for (u8 i = 0; i < MAX_TEXTURES; i++) {
|
for (u8 i = 0; i < MAX_TEXTURES; i++) {
|
||||||
auto& bound_texture = render_state.textures[stage][i];
|
auto& bound_texture = render_state.textures[stage][i];
|
||||||
|
@ -56,6 +58,7 @@ void CommandRecorder::BeginOrContinueRenderPass(MTL::RenderPassDescriptor* rende
|
||||||
bound_texture.needs_update = false;
|
bound_texture.needs_update = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sampler states
|
// Sampler states
|
||||||
for (u8 i = 0; i < MAX_SAMPLERS; i++) {
|
for (u8 i = 0; i < MAX_SAMPLERS; i++) {
|
||||||
auto& bound_sampler_state = render_state.sampler_states[stage][i];
|
auto& bound_sampler_state = render_state.sampler_states[stage][i];
|
||||||
|
@ -78,20 +81,6 @@ void CommandRecorder::BeginOrContinueRenderPass(MTL::RenderPassDescriptor* rende
|
||||||
|
|
||||||
bind_resources(0);
|
bind_resources(0);
|
||||||
bind_resources(4);
|
bind_resources(4);
|
||||||
|
|
||||||
if (should_reset_bound_resources) {
|
|
||||||
for (size_t stage = 0; stage < 5; stage++) {
|
|
||||||
for (u8 i = 0; i < MAX_BUFFERS; i++) {
|
|
||||||
render_state.buffers[stage][i].buffer = nullptr;
|
|
||||||
}
|
|
||||||
for (u8 i = 0; i < MAX_TEXTURES; i++) {
|
|
||||||
render_state.textures[stage][i].texture = nullptr;
|
|
||||||
}
|
|
||||||
for (u8 i = 0; i < MAX_SAMPLERS; i++) {
|
|
||||||
render_state.sampler_states[stage][i].sampler_state = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandRecorder::RequireComputeEncoder() {
|
void CommandRecorder::RequireComputeEncoder() {
|
||||||
|
|
|
@ -114,7 +114,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void SetBuffer(size_t stage, MTL::Buffer* buffer, size_t index, size_t offset) {
|
inline void SetBuffer(size_t stage, MTL::Buffer* buffer, size_t offset, size_t index) {
|
||||||
auto& bound_buffer = render_state.buffers[stage][index];
|
auto& bound_buffer = render_state.buffers[stage][index];
|
||||||
if (buffer != bound_buffer.buffer) {
|
if (buffer != bound_buffer.buffer) {
|
||||||
bound_buffer = {true, buffer, offset};
|
bound_buffer = {true, buffer, offset};
|
||||||
|
|
Loading…
Reference in a new issue