mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
Merge pull request #5231 from ReinUsesLisp/dyn-bindings
renderer_vulkan/fixed_pipeline_state: Move enabled bindings to static state
This commit is contained in:
commit
8eea7c1176
|
@ -76,7 +76,7 @@ void FixedPipelineState::Fill(const Maxwell& regs, bool has_extended_dynamic_sta
|
||||||
regs.instanced_arrays.IsInstancingEnabled(index) ? regs.vertex_array[index].divisor : 0;
|
regs.instanced_arrays.IsInstancingEnabled(index) ? regs.vertex_array[index].divisor : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::size_t index = 0; index < Maxwell::NumVertexAttributes; ++index) {
|
for (size_t index = 0; index < Maxwell::NumVertexAttributes; ++index) {
|
||||||
const auto& input = regs.vertex_attrib_format[index];
|
const auto& input = regs.vertex_attrib_format[index];
|
||||||
auto& attribute = attributes[index];
|
auto& attribute = attributes[index];
|
||||||
attribute.raw = 0;
|
attribute.raw = 0;
|
||||||
|
@ -85,6 +85,7 @@ void FixedPipelineState::Fill(const Maxwell& regs, bool has_extended_dynamic_sta
|
||||||
attribute.offset.Assign(input.offset);
|
attribute.offset.Assign(input.offset);
|
||||||
attribute.type.Assign(static_cast<u32>(input.type.Value()));
|
attribute.type.Assign(static_cast<u32>(input.type.Value()));
|
||||||
attribute.size.Assign(static_cast<u32>(input.size.Value()));
|
attribute.size.Assign(static_cast<u32>(input.size.Value()));
|
||||||
|
attribute.binding_index_enabled.Assign(regs.vertex_array[index].IsEnabled() ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::size_t index = 0; index < std::size(attachments); ++index) {
|
for (std::size_t index = 0; index < std::size(attachments); ++index) {
|
||||||
|
@ -172,14 +173,9 @@ void FixedPipelineState::DynamicState::Fill(const Maxwell& regs) {
|
||||||
depth_test_func.Assign(PackComparisonOp(regs.depth_test_func));
|
depth_test_func.Assign(PackComparisonOp(regs.depth_test_func));
|
||||||
cull_face.Assign(PackCullFace(regs.cull_face));
|
cull_face.Assign(PackCullFace(regs.cull_face));
|
||||||
cull_enable.Assign(regs.cull_test_enabled != 0 ? 1 : 0);
|
cull_enable.Assign(regs.cull_test_enabled != 0 ? 1 : 0);
|
||||||
|
std::ranges::transform(regs.vertex_array, vertex_strides.begin(), [](const auto& array) {
|
||||||
for (std::size_t index = 0; index < Maxwell::NumVertexArrays; ++index) {
|
return static_cast<u16>(array.stride.Value());
|
||||||
const auto& input = regs.vertex_array[index];
|
});
|
||||||
VertexBinding& binding = vertex_bindings[index];
|
|
||||||
binding.raw = 0;
|
|
||||||
binding.enabled.Assign(input.IsEnabled() ? 1 : 0);
|
|
||||||
binding.stride.Assign(static_cast<u16>(input.stride.Value()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t FixedPipelineState::Hash() const noexcept {
|
std::size_t FixedPipelineState::Hash() const noexcept {
|
||||||
|
|
|
@ -96,6 +96,8 @@ struct FixedPipelineState {
|
||||||
BitField<6, 14, u32> offset;
|
BitField<6, 14, u32> offset;
|
||||||
BitField<20, 3, u32> type;
|
BitField<20, 3, u32> type;
|
||||||
BitField<23, 6, u32> size;
|
BitField<23, 6, u32> size;
|
||||||
|
// Not really an element of a vertex attribute, but it can be packed here
|
||||||
|
BitField<29, 1, u32> binding_index_enabled;
|
||||||
|
|
||||||
constexpr Maxwell::VertexAttribute::Type Type() const noexcept {
|
constexpr Maxwell::VertexAttribute::Type Type() const noexcept {
|
||||||
return static_cast<Maxwell::VertexAttribute::Type>(type.Value());
|
return static_cast<Maxwell::VertexAttribute::Type>(type.Value());
|
||||||
|
@ -130,12 +132,6 @@ struct FixedPipelineState {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
union VertexBinding {
|
|
||||||
u16 raw;
|
|
||||||
BitField<0, 12, u16> stride;
|
|
||||||
BitField<12, 1, u16> enabled;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DynamicState {
|
struct DynamicState {
|
||||||
union {
|
union {
|
||||||
u32 raw1;
|
u32 raw1;
|
||||||
|
@ -153,7 +149,8 @@ struct FixedPipelineState {
|
||||||
BitField<0, 2, u32> cull_face;
|
BitField<0, 2, u32> cull_face;
|
||||||
BitField<2, 1, u32> cull_enable;
|
BitField<2, 1, u32> cull_enable;
|
||||||
};
|
};
|
||||||
std::array<VertexBinding, Maxwell::NumVertexArrays> vertex_bindings;
|
// Vertex stride is a 12 bits value, we have 4 bits to spare per element
|
||||||
|
std::array<u16, Maxwell::NumVertexArrays> vertex_strides;
|
||||||
|
|
||||||
void Fill(const Maxwell& regs);
|
void Fill(const Maxwell& regs);
|
||||||
|
|
||||||
|
|
|
@ -212,11 +212,7 @@ vk::Pipeline VKGraphicsPipeline::CreatePipeline(const SPIRVProgram& program,
|
||||||
// state is ignored
|
// state is ignored
|
||||||
dynamic.raw1 = 0;
|
dynamic.raw1 = 0;
|
||||||
dynamic.raw2 = 0;
|
dynamic.raw2 = 0;
|
||||||
for (FixedPipelineState::VertexBinding& binding : dynamic.vertex_bindings) {
|
dynamic.vertex_strides.fill(0);
|
||||||
// Enable all vertex bindings
|
|
||||||
binding.raw = 0;
|
|
||||||
binding.enabled.Assign(1);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
dynamic = state.dynamic_state;
|
dynamic = state.dynamic_state;
|
||||||
}
|
}
|
||||||
|
@ -224,19 +220,16 @@ vk::Pipeline VKGraphicsPipeline::CreatePipeline(const SPIRVProgram& program,
|
||||||
std::vector<VkVertexInputBindingDescription> vertex_bindings;
|
std::vector<VkVertexInputBindingDescription> vertex_bindings;
|
||||||
std::vector<VkVertexInputBindingDivisorDescriptionEXT> vertex_binding_divisors;
|
std::vector<VkVertexInputBindingDivisorDescriptionEXT> vertex_binding_divisors;
|
||||||
for (std::size_t index = 0; index < Maxwell::NumVertexArrays; ++index) {
|
for (std::size_t index = 0; index < Maxwell::NumVertexArrays; ++index) {
|
||||||
const auto& binding = dynamic.vertex_bindings[index];
|
if (state.attributes[index].binding_index_enabled == 0) {
|
||||||
if (!binding.enabled) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const bool instanced = state.binding_divisors[index] != 0;
|
const bool instanced = state.binding_divisors[index] != 0;
|
||||||
const auto rate = instanced ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX;
|
const auto rate = instanced ? VK_VERTEX_INPUT_RATE_INSTANCE : VK_VERTEX_INPUT_RATE_VERTEX;
|
||||||
|
|
||||||
vertex_bindings.push_back({
|
vertex_bindings.push_back({
|
||||||
.binding = static_cast<u32>(index),
|
.binding = static_cast<u32>(index),
|
||||||
.stride = binding.stride,
|
.stride = dynamic.vertex_strides[index],
|
||||||
.inputRate = rate,
|
.inputRate = rate,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (instanced) {
|
if (instanced) {
|
||||||
vertex_binding_divisors.push_back({
|
vertex_binding_divisors.push_back({
|
||||||
.binding = static_cast<u32>(index),
|
.binding = static_cast<u32>(index),
|
||||||
|
|
Loading…
Reference in a new issue