Merge pull request #2657 from oneandonlydean/up2/address-draw-key
perf(agc): skip the resource-cache key and lookup for address-based draws
This commit is contained in:
commit
5edae35361
|
|
@ -184,6 +184,7 @@ public:
|
|||
// ranges are fixed by the build), so a Revalidate's collects on the same worker are memo hits.
|
||||
void PrecollectSurfaces() const;
|
||||
bool Reusable() const { return reusable; }
|
||||
static bool NeverReusable(std::span<const CompiledShader> shaders);
|
||||
// `shaders` are the stages the object was built from, in build order (a recorded draw's vertex
|
||||
// and fragment stages, or one compute stage): their bindings are walked like the build did.
|
||||
// How a Revalidate proved (or refused) the object, for the [recipe] line: the proof path taken
|
||||
|
|
|
|||
|
|
@ -1223,7 +1223,7 @@ ResolvedResources resolveDrawResources(const Context& context, const State& stat
|
|||
// The render target and index ranges stay out of the key (see DrawResourceKey); a hit repeats
|
||||
// the alias checks instead. Debug aid: APS5_NO_DRAW_KEY_TRIM=1 keys them as before.
|
||||
static const bool trimKey = std::getenv("APS5_NO_DRAW_KEY_TRIM") == nullptr;
|
||||
resolved.cacheable = recordable && !noDrawResourceCache && !noTextureCache && std::all_of(shaders.begin(), shaders.end(), [](const CompiledShader& shader) { return shader.program != nullptr && shader.program->PipelineVariantId() != 0; });
|
||||
resolved.cacheable = recordable && !noDrawResourceCache && !noTextureCache && std::all_of(shaders.begin(), shaders.end(), [](const CompiledShader& shader) { return shader.program != nullptr && shader.program->PipelineVariantId() != 0; }) && !ShaderResources::NeverReusable(shaders);
|
||||
if (resolved.cacheable) {
|
||||
resolved.contentKey = DrawResourceKey(context, shaders, state.color, static_cast<std::uint32_t>(state.colors.size()), draw.indexAddress, indexBytes, !trimKey);
|
||||
if (auto cached = SharedResourceCache().Find(resolved.contentKey)) {
|
||||
|
|
|
|||
|
|
@ -1529,6 +1529,12 @@ void ShaderResources::noteReusable() {
|
|||
reusable = true;
|
||||
}
|
||||
|
||||
bool ShaderResources::NeverReusable(std::span<const CompiledShader> shaders) {
|
||||
return std::any_of(shaders.begin(), shaders.end(), [](const CompiledShader& shader) {
|
||||
return shader.program != nullptr && std::any_of(shader.program->bindings.begin(), shader.program->bindings.end(), [](const ShaderRecompiler::DescriptorBinding& binding) { return binding.role == ShaderRecompiler::DescriptorRole::BdaPagetable || binding.role == ShaderRecompiler::DescriptorRole::FaultBuffer; });
|
||||
});
|
||||
}
|
||||
|
||||
// APS5_PROFILE_DRAW: the per-device descriptor caches' counters, every 10 s.
|
||||
void ShaderResources::reportDescriptorCaches() const {
|
||||
static std::mutex reportMutex;
|
||||
|
|
|
|||
|
|
@ -615,6 +615,7 @@ void RunBdaResourceTests(const Context& context, const BdaTestAccess& access) {
|
|||
const std::array<CompiledShader, 1> stages{{{ShaderRecompiler::ShaderStage::TessellationControl, &control, 0}}};
|
||||
const std::array<GuestMemorySnapshot, 1> unusedSnapshots{{{0, source}}};
|
||||
ShaderResources resources(disabled, stages, ColorTarget{}, 0, 0, 0, unusedSnapshots);
|
||||
Require(ShaderResources::NeverReusable(stages) && !resources.Reusable(), "a fault-buffer build is reusable");
|
||||
const auto fault = access.bytes(access.descriptor(5).buffer);
|
||||
for (const auto byte : fault) Require(byte == std::byte{}, "rect-list fault buffer was not initialized");
|
||||
const ShaderRecompiler::BdaAbi::Fault report{ShaderRecompiler::BdaAbi::FaultState::Ready, ShaderRecompiler::BdaAbi::FaultReason::InvalidRectangle, 0, 0, 0, 0, 0};
|
||||
|
|
@ -628,6 +629,11 @@ void RunBdaResourceTests(const Context& context, const BdaTestAccess& access) {
|
|||
}
|
||||
{
|
||||
ShaderResources resources(context, compiled, snapshots);
|
||||
Require(ShaderResources::NeverReusable(std::span<const CompiledShader>(&compiled, 1)) && !resources.Reusable(), "an address-based build is reusable");
|
||||
ShaderRecompiler::RecompileResult plain;
|
||||
plain.bindings = {binding(Role::GuestBuffers, 6)};
|
||||
const CompiledShader plainStage{ShaderRecompiler::ShaderStage::Compute, &plain, 0};
|
||||
Require(!ShaderResources::NeverReusable(std::span<const CompiledShader>(&plainStage, 1)), "a build without address tables or a fault buffer is refused the resource cache");
|
||||
const auto table = access.bytes(access.descriptor(4).buffer);
|
||||
ShaderRecompiler::BdaAbi::Header header{};
|
||||
ShaderRecompiler::BdaAbi::Range range{};
|
||||
|
|
|
|||
Loading…
Reference in New Issue