mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
Merge pull request #10749 from Morph1984/strong-typing
buffer_cache_base: Specify buffer type in HostBindings
This commit is contained in:
commit
702a2ac631
|
@ -715,7 +715,7 @@ void BufferCache<P>::BindHostIndexBuffer() {
|
||||||
|
|
||||||
template <class P>
|
template <class P>
|
||||||
void BufferCache<P>::BindHostVertexBuffers() {
|
void BufferCache<P>::BindHostVertexBuffers() {
|
||||||
HostBindings host_bindings;
|
HostBindings<typename P::Buffer> host_bindings;
|
||||||
bool any_valid{false};
|
bool any_valid{false};
|
||||||
auto& flags = maxwell3d->dirty.flags;
|
auto& flags = maxwell3d->dirty.flags;
|
||||||
for (u32 index = 0; index < NUM_VERTEX_BUFFERS; ++index) {
|
for (u32 index = 0; index < NUM_VERTEX_BUFFERS; ++index) {
|
||||||
|
@ -741,7 +741,7 @@ void BufferCache<P>::BindHostVertexBuffers() {
|
||||||
const u32 stride = maxwell3d->regs.vertex_streams[index].stride;
|
const u32 stride = maxwell3d->regs.vertex_streams[index].stride;
|
||||||
const u32 offset = buffer.Offset(binding.cpu_addr);
|
const u32 offset = buffer.Offset(binding.cpu_addr);
|
||||||
|
|
||||||
host_bindings.buffers.push_back(reinterpret_cast<void*>(&buffer));
|
host_bindings.buffers.push_back(&buffer);
|
||||||
host_bindings.offsets.push_back(offset);
|
host_bindings.offsets.push_back(offset);
|
||||||
host_bindings.sizes.push_back(binding.size);
|
host_bindings.sizes.push_back(binding.size);
|
||||||
host_bindings.strides.push_back(stride);
|
host_bindings.strides.push_back(stride);
|
||||||
|
@ -900,7 +900,7 @@ void BufferCache<P>::BindHostTransformFeedbackBuffers() {
|
||||||
if (maxwell3d->regs.transform_feedback_enabled == 0) {
|
if (maxwell3d->regs.transform_feedback_enabled == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HostBindings host_bindings;
|
HostBindings<typename P::Buffer> host_bindings;
|
||||||
for (u32 index = 0; index < NUM_TRANSFORM_FEEDBACK_BUFFERS; ++index) {
|
for (u32 index = 0; index < NUM_TRANSFORM_FEEDBACK_BUFFERS; ++index) {
|
||||||
const Binding& binding = channel_state->transform_feedback_buffers[index];
|
const Binding& binding = channel_state->transform_feedback_buffers[index];
|
||||||
if (maxwell3d->regs.transform_feedback.controls[index].varying_count == 0 &&
|
if (maxwell3d->regs.transform_feedback.controls[index].varying_count == 0 &&
|
||||||
|
@ -913,7 +913,7 @@ void BufferCache<P>::BindHostTransformFeedbackBuffers() {
|
||||||
SynchronizeBuffer(buffer, binding.cpu_addr, size);
|
SynchronizeBuffer(buffer, binding.cpu_addr, size);
|
||||||
|
|
||||||
const u32 offset = buffer.Offset(binding.cpu_addr);
|
const u32 offset = buffer.Offset(binding.cpu_addr);
|
||||||
host_bindings.buffers.push_back(reinterpret_cast<void*>(&buffer));
|
host_bindings.buffers.push_back(&buffer);
|
||||||
host_bindings.offsets.push_back(offset);
|
host_bindings.offsets.push_back(offset);
|
||||||
host_bindings.sizes.push_back(binding.size);
|
host_bindings.sizes.push_back(binding.size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,8 +105,9 @@ static constexpr Binding NULL_BINDING{
|
||||||
.buffer_id = NULL_BUFFER_ID,
|
.buffer_id = NULL_BUFFER_ID,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename Buffer>
|
||||||
struct HostBindings {
|
struct HostBindings {
|
||||||
boost::container::small_vector<void*, NUM_VERTEX_BUFFERS> buffers;
|
boost::container::small_vector<Buffer*, NUM_VERTEX_BUFFERS> buffers;
|
||||||
boost::container::small_vector<u64, NUM_VERTEX_BUFFERS> offsets;
|
boost::container::small_vector<u64, NUM_VERTEX_BUFFERS> offsets;
|
||||||
boost::container::small_vector<u64, NUM_VERTEX_BUFFERS> sizes;
|
boost::container::small_vector<u64, NUM_VERTEX_BUFFERS> sizes;
|
||||||
boost::container::small_vector<u64, NUM_VERTEX_BUFFERS> strides;
|
boost::container::small_vector<u64, NUM_VERTEX_BUFFERS> strides;
|
||||||
|
|
|
@ -232,11 +232,11 @@ void BufferCacheRuntime::BindVertexBuffer(u32 index, Buffer& buffer, u32 offset,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings& 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) {
|
||||||
BindVertexBuffer(
|
BindVertexBuffer(bindings.min_index + index, *bindings.buffers[index],
|
||||||
bindings.min_index + index, *reinterpret_cast<Buffer*>(bindings.buffers[index]),
|
static_cast<u32>(bindings.offsets[index]),
|
||||||
static_cast<u32>(bindings.offsets[index]), static_cast<u32>(bindings.sizes[index]),
|
static_cast<u32>(bindings.sizes[index]),
|
||||||
static_cast<u32>(bindings.strides[index]));
|
static_cast<u32>(bindings.strides[index]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -329,10 +329,9 @@ void BufferCacheRuntime::BindTransformFeedbackBuffer(u32 index, Buffer& buffer,
|
||||||
static_cast<GLintptr>(offset), static_cast<GLsizeiptr>(size));
|
static_cast<GLintptr>(offset), static_cast<GLsizeiptr>(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferCacheRuntime::BindTransformFeedbackBuffers(VideoCommon::HostBindings& bindings) {
|
void BufferCacheRuntime::BindTransformFeedbackBuffers(VideoCommon::HostBindings<Buffer>& bindings) {
|
||||||
for (u32 index = 0; index < bindings.buffers.size(); index++) {
|
for (u32 index = 0; index < bindings.buffers.size(); ++index) {
|
||||||
glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, index,
|
glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, index, bindings.buffers[index]->Handle(),
|
||||||
reinterpret_cast<Buffer*>(bindings.buffers[index])->Handle(),
|
|
||||||
static_cast<GLintptr>(bindings.offsets[index]),
|
static_cast<GLintptr>(bindings.offsets[index]),
|
||||||
static_cast<GLsizeiptr>(bindings.sizes[index]));
|
static_cast<GLsizeiptr>(bindings.sizes[index]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,8 @@ public:
|
||||||
void BindIndexBuffer(Buffer& buffer, u32 offset, u32 size);
|
void BindIndexBuffer(Buffer& buffer, u32 offset, u32 size);
|
||||||
|
|
||||||
void BindVertexBuffer(u32 index, Buffer& buffer, u32 offset, u32 size, u32 stride);
|
void BindVertexBuffer(u32 index, Buffer& buffer, u32 offset, u32 size, u32 stride);
|
||||||
void BindVertexBuffers(VideoCommon::HostBindings& bindings);
|
|
||||||
|
void BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings);
|
||||||
|
|
||||||
void BindUniformBuffer(size_t stage, u32 binding_index, Buffer& buffer, u32 offset, u32 size);
|
void BindUniformBuffer(size_t stage, u32 binding_index, Buffer& buffer, u32 offset, u32 size);
|
||||||
|
|
||||||
|
@ -100,7 +101,8 @@ public:
|
||||||
bool is_written);
|
bool is_written);
|
||||||
|
|
||||||
void BindTransformFeedbackBuffer(u32 index, Buffer& buffer, u32 offset, u32 size);
|
void BindTransformFeedbackBuffer(u32 index, Buffer& buffer, u32 offset, u32 size);
|
||||||
void BindTransformFeedbackBuffers(VideoCommon::HostBindings& bindings);
|
|
||||||
|
void BindTransformFeedbackBuffers(VideoCommon::HostBindings<Buffer>& bindings);
|
||||||
|
|
||||||
void BindTextureBuffer(Buffer& buffer, u32 offset, u32 size,
|
void BindTextureBuffer(Buffer& buffer, u32 offset, u32 size,
|
||||||
VideoCore::Surface::PixelFormat format);
|
VideoCore::Surface::PixelFormat format);
|
||||||
|
|
|
@ -501,11 +501,10 @@ void BufferCacheRuntime::BindVertexBuffer(u32 index, VkBuffer buffer, u32 offset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings& bindings) {
|
void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings) {
|
||||||
boost::container::small_vector<VkBuffer, 32> buffer_handles;
|
boost::container::small_vector<VkBuffer, 32> buffer_handles;
|
||||||
for (u32 index = 0; index < bindings.buffers.size(); index++) {
|
for (u32 index = 0; index < bindings.buffers.size(); ++index) {
|
||||||
auto& buffer = *reinterpret_cast<Buffer*>(bindings.buffers[index]);
|
auto handle = bindings.buffers[index]->Handle();
|
||||||
auto handle = buffer.Handle();
|
|
||||||
if (handle == VK_NULL_HANDLE) {
|
if (handle == VK_NULL_HANDLE) {
|
||||||
bindings.offsets[index] = 0;
|
bindings.offsets[index] = 0;
|
||||||
bindings.sizes[index] = VK_WHOLE_SIZE;
|
bindings.sizes[index] = VK_WHOLE_SIZE;
|
||||||
|
@ -521,16 +520,13 @@ void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings& bindings)
|
||||||
buffer_handles = buffer_handles](vk::CommandBuffer cmdbuf) {
|
buffer_handles = buffer_handles](vk::CommandBuffer cmdbuf) {
|
||||||
cmdbuf.BindVertexBuffers2EXT(
|
cmdbuf.BindVertexBuffers2EXT(
|
||||||
bindings.min_index, bindings.max_index - bindings.min_index, buffer_handles.data(),
|
bindings.min_index, bindings.max_index - bindings.min_index, buffer_handles.data(),
|
||||||
reinterpret_cast<const VkDeviceSize*>(bindings.offsets.data()),
|
bindings.offsets.data(), bindings.sizes.data(), bindings.strides.data());
|
||||||
reinterpret_cast<const VkDeviceSize*>(bindings.sizes.data()),
|
|
||||||
reinterpret_cast<const VkDeviceSize*>(bindings.strides.data()));
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
scheduler.Record([bindings = bindings,
|
scheduler.Record([bindings = bindings,
|
||||||
buffer_handles = buffer_handles](vk::CommandBuffer cmdbuf) {
|
buffer_handles = buffer_handles](vk::CommandBuffer cmdbuf) {
|
||||||
cmdbuf.BindVertexBuffers(
|
cmdbuf.BindVertexBuffers(bindings.min_index, bindings.max_index - bindings.min_index,
|
||||||
bindings.min_index, bindings.max_index - bindings.min_index, buffer_handles.data(),
|
buffer_handles.data(), bindings.offsets.data());
|
||||||
reinterpret_cast<const VkDeviceSize*>(bindings.offsets.data()));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -556,22 +552,20 @@ void BufferCacheRuntime::BindTransformFeedbackBuffer(u32 index, VkBuffer buffer,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferCacheRuntime::BindTransformFeedbackBuffers(VideoCommon::HostBindings& bindings) {
|
void BufferCacheRuntime::BindTransformFeedbackBuffers(VideoCommon::HostBindings<Buffer>& bindings) {
|
||||||
if (!device.IsExtTransformFeedbackSupported()) {
|
if (!device.IsExtTransformFeedbackSupported()) {
|
||||||
// Already logged in the rasterizer
|
// Already logged in the rasterizer
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boost::container::small_vector<VkBuffer, 4> buffer_handles;
|
boost::container::small_vector<VkBuffer, 4> buffer_handles;
|
||||||
for (u32 index = 0; index < bindings.buffers.size(); index++) {
|
for (u32 index = 0; index < bindings.buffers.size(); ++index) {
|
||||||
auto& buffer = *reinterpret_cast<Buffer*>(bindings.buffers[index]);
|
buffer_handles.push_back(bindings.buffers[index]->Handle());
|
||||||
buffer_handles.push_back(buffer.Handle());
|
|
||||||
}
|
}
|
||||||
scheduler.Record(
|
scheduler.Record(
|
||||||
[bindings = bindings, buffer_handles = buffer_handles](vk::CommandBuffer cmdbuf) {
|
[bindings = bindings, buffer_handles = buffer_handles](vk::CommandBuffer cmdbuf) {
|
||||||
cmdbuf.BindTransformFeedbackBuffersEXT(
|
cmdbuf.BindTransformFeedbackBuffersEXT(0, static_cast<u32>(buffer_handles.size()),
|
||||||
0, static_cast<u32>(buffer_handles.size()), buffer_handles.data(),
|
buffer_handles.data(), bindings.offsets.data(),
|
||||||
reinterpret_cast<const VkDeviceSize*>(bindings.offsets.data()),
|
bindings.sizes.data());
|
||||||
reinterpret_cast<const VkDeviceSize*>(bindings.sizes.data()));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,10 +97,12 @@ public:
|
||||||
void BindQuadIndexBuffer(PrimitiveTopology topology, u32 first, u32 count);
|
void BindQuadIndexBuffer(PrimitiveTopology topology, u32 first, u32 count);
|
||||||
|
|
||||||
void BindVertexBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size, u32 stride);
|
void BindVertexBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size, u32 stride);
|
||||||
void BindVertexBuffers(VideoCommon::HostBindings& bindings);
|
|
||||||
|
void BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings);
|
||||||
|
|
||||||
void BindTransformFeedbackBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size);
|
void BindTransformFeedbackBuffer(u32 index, VkBuffer buffer, u32 offset, u32 size);
|
||||||
void BindTransformFeedbackBuffers(VideoCommon::HostBindings& bindings);
|
|
||||||
|
void BindTransformFeedbackBuffers(VideoCommon::HostBindings<Buffer>& bindings);
|
||||||
|
|
||||||
std::span<u8> BindMappedUniformBuffer([[maybe_unused]] size_t stage,
|
std::span<u8> BindMappedUniformBuffer([[maybe_unused]] size_t stage,
|
||||||
[[maybe_unused]] u32 binding_index, u32 size) {
|
[[maybe_unused]] u32 binding_index, u32 size) {
|
||||||
|
|
Loading…
Reference in a new issue