Use hades HLE replacement for constant buffer attributes

In the cases of indirect draws, we don't know the vertex offset to write into the driver info constant buffer ahead of time, and to do it at draw time on the GPU would mean marking the constant buffer as GPU dirty (slow). HLE them in the shader instead using the host draw parameters extension.
This commit is contained in:
Billy Laws 2023-02-04 22:35:34 +00:00
parent 7e1c58accc
commit 2b93604da0

View File

@ -213,11 +213,24 @@ namespace skyline::gpu {
} }
[[nodiscard]] bool HasHLEMacroState() const final { [[nodiscard]] bool HasHLEMacroState() const final {
return false; return stage == Shader::Stage::VertexB || stage == Shader::Stage::VertexA;
} }
[[nodiscard]] std::optional<Shader::ReplaceConstant> GetReplaceConstBuffer(u32 bank, u32 offset) final { [[nodiscard]] std::optional<Shader::ReplaceConstant> GetReplaceConstBuffer(u32 bank, u32 offset) final {
return std::nullopt; if (bank != 0 || !is_propietary_driver)
return std::nullopt;
// Replace constant buffer offsets containing draw parameters with the appropriate shader attribute, required as e.g. in the case of indirect draws the constant buffer contents won't be entirely correct for these specific parameters
switch (offset) {
case 0x640:
return Shader::ReplaceConstant::BaseVertex;
case 0x644:
return Shader::ReplaceConstant::BaseInstance;
case 0x648:
return Shader::ReplaceConstant::DrawID;
default:
return std::nullopt;
}
} }
void Dump(u64 hash) final {} void Dump(u64 hash) final {}