mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-25 16:08:59 +02:00
[vulkan] Adjustment VK_EXT_transform_feedback & VK_EXT_conditional_rendering
This commit is contained in:
parent
1b9d6703f5
commit
c07dfa6fb4
3 changed files with 38 additions and 31 deletions
|
|
@ -10,6 +10,7 @@
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "common/settings.h"
|
||||||
#include "video_core/buffer_cache/buffer_cache_base.h"
|
#include "video_core/buffer_cache/buffer_cache_base.h"
|
||||||
#include "video_core/renderer_vulkan/vk_buffer_cache.h"
|
#include "video_core/renderer_vulkan/vk_buffer_cache.h"
|
||||||
|
|
||||||
|
|
@ -556,7 +557,9 @@ void BufferCacheRuntime::BindVertexBuffer(u32 index, VkBuffer buffer, u32 offset
|
||||||
if (index >= device.GetMaxVertexInputBindings()) {
|
if (index >= device.GetMaxVertexInputBindings()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (device.IsExtExtendedDynamicStateSupported()) {
|
const bool use_dynamic_vertex_input = device.IsExtVertexInputDynamicStateSupported() &&
|
||||||
|
Settings::values.vertex_input_dynamic_state.GetValue();
|
||||||
|
if (device.IsExtExtendedDynamicStateSupported() && !use_dynamic_vertex_input) {
|
||||||
scheduler.Record([index, buffer, offset, size, stride](vk::CommandBuffer cmdbuf) {
|
scheduler.Record([index, buffer, offset, size, stride](vk::CommandBuffer cmdbuf) {
|
||||||
const VkDeviceSize vk_offset = buffer != VK_NULL_HANDLE ? offset : 0;
|
const VkDeviceSize vk_offset = buffer != VK_NULL_HANDLE ? offset : 0;
|
||||||
const VkDeviceSize vk_size = buffer != VK_NULL_HANDLE ? size : VK_WHOLE_SIZE;
|
const VkDeviceSize vk_size = buffer != VK_NULL_HANDLE ? size : VK_WHOLE_SIZE;
|
||||||
|
|
@ -596,7 +599,9 @@ void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bi
|
||||||
if (binding_count == 0) {
|
if (binding_count == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (device.IsExtExtendedDynamicStateSupported()) {
|
const bool use_dynamic_vertex_input = device.IsExtVertexInputDynamicStateSupported() &&
|
||||||
|
Settings::values.vertex_input_dynamic_state.GetValue();
|
||||||
|
if (device.IsExtExtendedDynamicStateSupported() && !use_dynamic_vertex_input) {
|
||||||
scheduler.Record([bindings_ = std::move(bindings), buffer_handles_ = std::move(buffer_handles), binding_count](vk::CommandBuffer cmdbuf) {
|
scheduler.Record([bindings_ = std::move(bindings), buffer_handles_ = std::move(buffer_handles), binding_count](vk::CommandBuffer cmdbuf) {
|
||||||
cmdbuf.BindVertexBuffers2EXT(bindings_.min_index, binding_count, buffer_handles_.data(), bindings_.offsets.data(), bindings_.sizes.data(), bindings_.strides.data());
|
cmdbuf.BindVertexBuffers2EXT(bindings_.min_index, binding_count, buffer_handles_.data(), bindings_.offsets.data(), bindings_.sizes.data(), bindings_.strides.data());
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -461,7 +461,8 @@ void ConditionalRenderingResolvePass::Resolve(VkBuffer dst_buffer, VkBuffer src_
|
||||||
cmdbuf.PushConstants(*layout, VK_SHADER_STAGE_COMPUTE_BIT, uniforms);
|
cmdbuf.PushConstants(*layout, VK_SHADER_STAGE_COMPUTE_BIT, uniforms);
|
||||||
cmdbuf.Dispatch(1, 1, 1);
|
cmdbuf.Dispatch(1, 1, 1);
|
||||||
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, write_barrier);
|
VK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT, 0,
|
||||||
|
write_barrier);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -529,7 +530,7 @@ void QueriesPrefixScanPass::Run(VkBuffer accumulation_buffer, VkBuffer dst_buffe
|
||||||
const VkDescriptorSet set = descriptor_allocator.Commit();
|
const VkDescriptorSet set = descriptor_allocator.Commit();
|
||||||
device.GetLogical().UpdateDescriptorSet(set, *descriptor_template, descriptor_data);
|
device.GetLogical().UpdateDescriptorSet(set, *descriptor_template, descriptor_data);
|
||||||
|
|
||||||
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, read_barrier);
|
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, read_barrier);
|
||||||
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_COMPUTE, *pipeline);
|
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_COMPUTE, *pipeline);
|
||||||
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_COMPUTE, *layout, 0, set, {});
|
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_COMPUTE, *layout, 0, set, {});
|
||||||
|
|
|
||||||
|
|
@ -1750,38 +1750,31 @@ void RasterizerVulkan::UpdateVertexInput(Tegra::Engines::Maxwell3D::Regs& regs)
|
||||||
boost::container::static_vector<VkVertexInputBindingDescription2EXT, 32> bindings;
|
boost::container::static_vector<VkVertexInputBindingDescription2EXT, 32> bindings;
|
||||||
boost::container::static_vector<VkVertexInputAttributeDescription2EXT, 32> attributes;
|
boost::container::static_vector<VkVertexInputAttributeDescription2EXT, 32> attributes;
|
||||||
|
|
||||||
// There seems to be a bug on Nvidia's driver where updating only higher attributes ends up
|
const u32 max_attributes =
|
||||||
// generating dirty state. Track the highest dirty attribute and update all attributes until
|
static_cast<u32>(std::min<size_t>(Maxwell::NumVertexAttributes,
|
||||||
// that one.
|
device.GetMaxVertexInputAttributes()));
|
||||||
size_t highest_dirty_attr{};
|
const u32 max_bindings =
|
||||||
for (size_t index = 0; index < Maxwell::NumVertexAttributes; ++index) {
|
static_cast<u32>(std::min<size_t>(Maxwell::NumVertexArrays,
|
||||||
if (dirty[Dirty::VertexAttribute0 + index]) {
|
device.GetMaxVertexInputBindings()));
|
||||||
highest_dirty_attr = index;
|
|
||||||
}
|
|
||||||
}
|
for (u32 index = 0; index < max_attributes; ++index) {
|
||||||
for (size_t index = 0; index < highest_dirty_attr; ++index) {
|
|
||||||
const Maxwell::VertexAttribute attribute{regs.vertex_attrib_format[index]};
|
const Maxwell::VertexAttribute attribute{regs.vertex_attrib_format[index]};
|
||||||
const u32 binding{attribute.buffer};
|
const u32 binding{attribute.buffer};
|
||||||
dirty[Dirty::VertexAttribute0 + index] = false;
|
if (attribute.constant || binding >= max_bindings) {
|
||||||
dirty[Dirty::VertexBinding0 + static_cast<size_t>(binding)] = true;
|
continue;
|
||||||
if (!attribute.constant) {
|
}
|
||||||
attributes.push_back({
|
attributes.push_back({
|
||||||
.sType = VK_STRUCTURE_TYPE_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION_2_EXT,
|
.sType = VK_STRUCTURE_TYPE_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION_2_EXT,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
.location = static_cast<u32>(index),
|
.location = index,
|
||||||
.binding = binding,
|
.binding = binding,
|
||||||
.format = MaxwellToVK::VertexFormat(device, attribute.type, attribute.size),
|
.format = MaxwellToVK::VertexFormat(device, attribute.type, attribute.size),
|
||||||
.offset = attribute.offset,
|
.offset = attribute.offset,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
for (size_t index = 0; index < Maxwell::NumVertexAttributes; ++index) {
|
|
||||||
if (!dirty[Dirty::VertexBinding0 + index]) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
dirty[Dirty::VertexBinding0 + index] = false;
|
|
||||||
|
|
||||||
const u32 binding{static_cast<u32>(index)};
|
for (u32 binding = 0; binding < max_bindings; ++binding) {
|
||||||
const auto& input_binding{regs.vertex_streams[binding]};
|
const auto& input_binding{regs.vertex_streams[binding]};
|
||||||
const bool is_instanced{regs.vertex_stream_instances.IsInstancingEnabled(binding)};
|
const bool is_instanced{regs.vertex_stream_instances.IsInstancingEnabled(binding)};
|
||||||
bindings.push_back({
|
bindings.push_back({
|
||||||
|
|
@ -1793,6 +1786,14 @@ void RasterizerVulkan::UpdateVertexInput(Tegra::Engines::Maxwell3D::Regs& regs)
|
||||||
.divisor = is_instanced ? input_binding.frequency : 1,
|
.divisor = is_instanced ? input_binding.frequency : 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (size_t index = 0; index < Maxwell::NumVertexAttributes; ++index) {
|
||||||
|
dirty[Dirty::VertexAttribute0 + index] = false;
|
||||||
|
}
|
||||||
|
for (size_t index = 0; index < Maxwell::NumVertexArrays; ++index) {
|
||||||
|
dirty[Dirty::VertexBinding0 + index] = false;
|
||||||
|
}
|
||||||
|
|
||||||
scheduler.Record([bindings, attributes](vk::CommandBuffer cmdbuf) {
|
scheduler.Record([bindings, attributes](vk::CommandBuffer cmdbuf) {
|
||||||
cmdbuf.SetVertexInputEXT(bindings, attributes);
|
cmdbuf.SetVertexInputEXT(bindings, attributes);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue