|
|
|
@ -1758,61 +1758,60 @@ void RasterizerVulkan::UpdateStencilTestEnable(Tegra::Engines::Maxwell3D::Regs& |
|
|
|
} |
|
|
|
|
|
|
|
void RasterizerVulkan::UpdateVertexInput(Tegra::Engines::Maxwell3D::Regs& regs) { |
|
|
|
auto& dirty{maxwell3d->dirty.flags}; |
|
|
|
if (!dirty[Dirty::VertexInput]) { |
|
|
|
return; |
|
|
|
} |
|
|
|
dirty[Dirty::VertexInput] = false; |
|
|
|
|
|
|
|
boost::container::static_vector<VkVertexInputBindingDescription2EXT, 32> bindings; |
|
|
|
boost::container::static_vector<VkVertexInputAttributeDescription2EXT, 32> attributes; |
|
|
|
|
|
|
|
// There seems to be a bug on Nvidia's driver where updating only higher attributes ends up
|
|
|
|
// generating dirty state. Track the highest dirty attribute and update all attributes until
|
|
|
|
// that one.
|
|
|
|
size_t highest_dirty_attr{}; |
|
|
|
for (size_t index = 0; index < Maxwell::NumVertexAttributes; ++index) { |
|
|
|
if (dirty[Dirty::VertexAttribute0 + index]) { |
|
|
|
highest_dirty_attr = index; |
|
|
|
auto& dirty = maxwell3d->dirty.flags; |
|
|
|
if (dirty[Dirty::VertexInput]) { |
|
|
|
dirty[Dirty::VertexInput] = false; |
|
|
|
boost::container::static_vector<VkVertexInputBindingDescription2EXT, Maxwell::NumVertexAttributes> bindings; |
|
|
|
boost::container::static_vector<VkVertexInputAttributeDescription2EXT, Maxwell::NumVertexAttributes> attributes; |
|
|
|
// There seems to be a bug on Nvidia's driver where updating only higher attributes ends up
|
|
|
|
// generating dirty state. Track the highest dirty attribute and update all attributes until
|
|
|
|
// that one.
|
|
|
|
size_t highest_dirty_attr = 0; |
|
|
|
if (device.IsNvidia()) { |
|
|
|
for (size_t i = 0; i < Maxwell::NumVertexAttributes; ++i) |
|
|
|
if (dirty[Dirty::VertexAttribute0 + i]) |
|
|
|
highest_dirty_attr = i; |
|
|
|
} else { |
|
|
|
highest_dirty_attr = Maxwell::NumVertexAttributes; |
|
|
|
} |
|
|
|
} |
|
|
|
for (size_t index = 0; index < highest_dirty_attr; ++index) { |
|
|
|
const Maxwell::VertexAttribute attribute{regs.vertex_attrib_format[index]}; |
|
|
|
const u32 binding{attribute.buffer}; |
|
|
|
dirty[Dirty::VertexAttribute0 + index] = false; |
|
|
|
dirty[Dirty::VertexBinding0 + static_cast<size_t>(binding)] = true; |
|
|
|
if (!attribute.constant) { |
|
|
|
attributes.push_back({ |
|
|
|
.sType = VK_STRUCTURE_TYPE_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION_2_EXT, |
|
|
|
.pNext = nullptr, |
|
|
|
.location = static_cast<u32>(index), |
|
|
|
.binding = binding, |
|
|
|
.format = MaxwellToVK::VertexFormat(device, attribute.type, attribute.size), |
|
|
|
.offset = attribute.offset, |
|
|
|
}); |
|
|
|
for (size_t i = 0; i < highest_dirty_attr; ++i) { |
|
|
|
if (dirty[Dirty::VertexAttribute0 + i]) { |
|
|
|
dirty[Dirty::VertexAttribute0 + i] = false; |
|
|
|
Maxwell::VertexAttribute const attribute = regs.vertex_attrib_format[i]; |
|
|
|
u32 const binding = attribute.buffer; |
|
|
|
dirty[Dirty::VertexBinding0 + size_t(binding)] = true; |
|
|
|
if (!attribute.constant) { |
|
|
|
attributes.push_back({ |
|
|
|
.sType = VK_STRUCTURE_TYPE_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION_2_EXT, |
|
|
|
.pNext = nullptr, |
|
|
|
.location = u32(i), |
|
|
|
.binding = binding, |
|
|
|
.format = MaxwellToVK::VertexFormat(device, attribute.type, attribute.size), |
|
|
|
.offset = attribute.offset, |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
for (size_t index = 0; index < Maxwell::NumVertexAttributes; ++index) { |
|
|
|
if (!dirty[Dirty::VertexBinding0 + index]) { |
|
|
|
continue; |
|
|
|
for (size_t i = 0; i < Maxwell::NumVertexAttributes; ++i) { |
|
|
|
if (dirty[Dirty::VertexBinding0 + i]) { |
|
|
|
dirty[Dirty::VertexBinding0 + i] = false; |
|
|
|
const u32 binding = u32(i); |
|
|
|
const auto& input_binding = regs.vertex_streams[binding]; |
|
|
|
const bool is_instanced = regs.vertex_stream_instances.IsInstancingEnabled(binding); |
|
|
|
bindings.push_back({ |
|
|
|
.sType = VK_STRUCTURE_TYPE_VERTEX_INPUT_BINDING_DESCRIPTION_2_EXT, |
|
|
|
.pNext = nullptr, |
|
|
|
.binding = binding, |
|
|
|
.stride = input_binding.stride, |
|
|
|
.inputRate = is_instanced ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX, |
|
|
|
.divisor = is_instanced ? input_binding.frequency : 1, |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
dirty[Dirty::VertexBinding0 + index] = false; |
|
|
|
|
|
|
|
const u32 binding{static_cast<u32>(index)}; |
|
|
|
const auto& input_binding{regs.vertex_streams[binding]}; |
|
|
|
const bool is_instanced{regs.vertex_stream_instances.IsInstancingEnabled(binding)}; |
|
|
|
bindings.push_back({ |
|
|
|
.sType = VK_STRUCTURE_TYPE_VERTEX_INPUT_BINDING_DESCRIPTION_2_EXT, |
|
|
|
.pNext = nullptr, |
|
|
|
.binding = binding, |
|
|
|
.stride = input_binding.stride, |
|
|
|
.inputRate = is_instanced ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX, |
|
|
|
.divisor = is_instanced ? input_binding.frequency : 1, |
|
|
|
scheduler.Record([bindings, attributes](vk::CommandBuffer cmdbuf) { |
|
|
|
cmdbuf.SetVertexInputEXT(bindings, attributes); |
|
|
|
}); |
|
|
|
} |
|
|
|
scheduler.Record([bindings, attributes](vk::CommandBuffer cmdbuf) { |
|
|
|
cmdbuf.SetVertexInputEXT(bindings, attributes); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
void RasterizerVulkan::InitializeChannel(Tegra::Control::ChannelState& channel) { |
|
|
|
|