Transition input assembly state to pipeline cache key

This commit is contained in:
Billy Laws 2022-09-06 18:41:29 +01:00
parent 3f9161fb74
commit ae5d419586
2 changed files with 25 additions and 28 deletions

View File

@ -320,8 +320,11 @@ namespace skyline::gpu::interconnect::maxwell3d {
manager.Bind(handle, primitiveRestartEnable);
}
const vk::PipelineInputAssemblyStateCreateInfo &InputAssemblyState::Build() {
return inputAssemblyState;
InputAssemblyState::InputAssemblyState(const EngineRegisters &engine) : engine{engine} {}
void InputAssemblyState::Update(Key &key) {
key.topology = currentEngineTopology;
key.primitiveRestartEnabled = engine.primitiveRestartEnable & 1;
}
static std::pair<vk::PrimitiveTopology, Shader::InputTopology> ConvertPrimitiveTopology(engine::DrawTopology topology) {
@ -359,9 +362,6 @@ namespace skyline::gpu::interconnect::maxwell3d {
void InputAssemblyState::SetPrimitiveTopology(engine::DrawTopology topology) {
currentEngineTopology = topology;
Shader::InputTopology geometryTopology{};
std::tie(inputAssemblyState.topology, geometryTopology) = ConvertPrimitiveTopology(topology);
/*
if (shaderTopology == ShaderCompiler::InputTopology::Points)
UpdateRuntimeInformation(runtimeInfo.fixed_state_point_size, std::make_optional(pointSpriteSize), maxwell3d::PipelineStage::Vertex, maxwell3d::PipelineStage::Geometry);
@ -380,9 +380,6 @@ namespace skyline::gpu::interconnect::maxwell3d {
return currentEngineTopology == engine::DrawTopology::Quads;
}
void InputAssemblyState::SetPrimitiveRestart(bool enabled) {
inputAssemblyState.primitiveRestartEnable = enabled;
}
/* Tessellation State */
void TessellationState::EngineRegisters::DirtyBind(DirtyManager &manager, dirty::Handle handle) const {
@ -779,7 +776,8 @@ namespace skyline::gpu::interconnect::maxwell3d {
vertexInput{manager, engine.vertexInputRegisters},
rasterization{manager, engine.rasterizationRegisters},
depthStencil{manager, engine.depthStencilRegisters},
colorBlend{manager, engine.colorBlendRegisters} {}
colorBlend{manager, engine.colorBlendRegisters},
directState{engine.inputAssemblyRegisters} {}
void PipelineState::Flush(InterconnectContext &ctx, StateUpdateBuilder &builder) {
boost::container::static_vector<TextureView *, engine::ColorTargetCount> colorAttachments;
@ -790,7 +788,8 @@ namespace skyline::gpu::interconnect::maxwell3d {
TextureView *depthAttachment{depthRenderTarget.UpdateGet(ctx, key).view.get()};
vertexInput.Update(key);
const auto &inputAssemblyState{directState.inputAssembly.Build()};
directState.inputAssembly.Update(key);
const auto &tessellationState{directState.tessellation.Build()};
const auto &rasterizationState{rasterization.UpdateGet().rasterizationState};
vk::PipelineMultisampleStateCreateInfo multisampleState{

View File

@ -6,12 +6,14 @@
#include <boost/container/static_vector.hpp>
#include <gpu/texture/texture.h>
#include "common.h"
#include "soc/gm20b/engines/maxwell/types.h"
namespace skyline::gpu::interconnect::maxwell3d {
class Key {
private:
struct Key {
struct {
u8 ztFormat : 5; // ZtFormat - 0xA as u8
u8 ztFormat : 5; //!< Use {Set, Get}ZtFormat. ZtFormat - 0xA as u8
engine::DrawTopology topology : 4;
bool primitiveRestartEnabled : 1;
};
struct VertexBinding {
@ -23,10 +25,8 @@ namespace skyline::gpu::interconnect::maxwell3d {
};
static_assert(sizeof(VertexBinding) == 0x8);
std::array<u8, engine::ColorTargetCount> ctFormats; //!< ColorTarget::Format as u8
std::array<VertexBinding, engine::VertexStreamCount> vertexBindings;
public:
std::array<u8, engine::ColorTargetCount> ctFormats; //!< Use {Set, Get}CtFormat. ColorTarget::Format as u8
std::array<VertexBinding, engine::VertexStreamCount> vertexBindings; //!< Use {Set, Get}VertexBinding
std::array<engine::VertexAttribute, engine::VertexAttributeCount> vertexAttributes;
void SetCtFormat(size_t index, engine::ColorTarget::Format format) {
@ -109,11 +109,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
void Flush(Key &key);
};
struct InputAssemblyState {
private:
vk::PipelineInputAssemblyStateCreateInfo inputAssemblyState{};
engine::DrawTopology currentEngineTopology{};
class InputAssemblyState {
public:
struct EngineRegisters {
const u32 &primitiveRestartEnable;
@ -121,19 +117,21 @@ namespace skyline::gpu::interconnect::maxwell3d {
void DirtyBind(DirtyManager &manager, dirty::Handle handle) const;
};
private:
EngineRegisters engine;
vk::PipelineInputAssemblyStateCreateInfo inputAssemblyState{};
engine::DrawTopology currentEngineTopology{};
const vk::PipelineInputAssemblyStateCreateInfo &Build();
public:
InputAssemblyState(const EngineRegisters &engine);
void Update(Key &key);
/**
* @note Calling this *REQUIRES* manually marking the pipeline as dirty
*/
void SetPrimitiveTopology(engine::DrawTopology topology);
engine::DrawTopology GetPrimitiveTopology() const;
bool NeedsQuadConversion() const;
void SetPrimitiveRestart(bool enable);
};
struct TessellationState {