diff --git a/CMakeLists.txt b/CMakeLists.txt index a6cd97c823..d0fd2651a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1136,10 +1136,14 @@ foreach(backend IN ITEMS warp hardware) add_test(NAME startup_indirect_draw_indexed_${backend} COMMAND startup_indirect_draw_indexed ${backend}) add_test(NAME startup_indirect_draw_${backend} COMMAND startup_indirect_draw_indexed ${backend} draw) add_test(NAME startup_indirect_translated_draw_${backend} COMMAND startup_indirect_draw_indexed ${backend} translated) + add_test(NAME startup_indirect_copy_provenance_${backend} COMMAND startup_indirect_draw_indexed ${backend} copy-provenance) + add_test(NAME startup_indirect_copy_provenance_off_${backend} COMMAND startup_indirect_draw_indexed ${backend} copy-provenance-off) add_test(NAME startup_indirect_mesh_${backend} COMMAND startup_indirect_draw_indexed ${backend} mesh) set_tests_properties(startup_indirect_draw_indexed_${backend} startup_indirect_draw_${backend} PROPERTIES TIMEOUT 30) set_tests_properties(startup_indirect_mesh_${backend} PROPERTIES TIMEOUT 30 SKIP_RETURN_CODE 77) set_tests_properties(startup_indirect_translated_draw_${backend} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77) + set_tests_properties(startup_indirect_copy_provenance_${backend} startup_indirect_copy_provenance_off_${backend} + PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77) endforeach() set_tests_properties(startup_indirect_draw_indexed_hardware startup_indirect_draw_hardware PROPERTIES SKIP_RETURN_CODE 77) # Negative control for the x2w-render indirect line: one forwarded call too many must be reported as a mismatch. diff --git a/docs/experiments.md b/docs/experiments.md index 4685f5d7a9..7603169516 100644 --- a/docs/experiments.md +++ b/docs/experiments.md @@ -31,6 +31,25 @@ The table's nonzero offset and stride select the second colour, the short view r non-aliased placement is refused. A raw descriptor over a recording-owned upload page reads the same colour and refuses a view that crosses its allocation. +### Same-recording GPU copies used by an indirect draw + +`X2W_TRANSLATED_INDIRECT_COPY_RANGES=1` enables a bounded handoff from slot 15 +`CopyBufferRegion` to the translated indirect draw. The latter still requires +`X2W_TRANSLATED_INDIRECT_DRAW=1`. A copied placed buffer qualifies only when one +validated GPU copy in the current recording completely supplied the requested view. +The source is a same-device desktop resource with no title shadow, a unique alias, +or an already covered range. Later overlapping copies invalidate earlier coverage. +The recording discards this proof at Close, so another recording needs its own writer. + +The source-built fixture reproduces a 68-byte request shape with source offset `0xbfffa0`. +Its compute writer fills the source with contrasting colours. The consumer reads red +from the second DWORD in the destination while the title-side green sentinel stays +unchanged. The disabled feature, a new recording using the same destination, a copy +of only 64 bytes, and an unproven overlapping write all leave the target clear. + +Run `cmake --build --preset release --target startup_indirect_draw_indexed` and +`ctest --preset release -j1 --no-tests=error -R '^startup_indirect_copy_provenance_' -V`. + ### Packed pixel position in a source-built shader Run `ctest --preset dev --no-tests=error -R '^startup_packed_screen_position_(hardware|warp)$' -V`. diff --git a/src/startup_stubs/d3d12_draw.inl b/src/startup_stubs/d3d12_draw.inl index 6f7366b30b..b28276e673 100644 --- a/src/startup_stubs/d3d12_draw.inl +++ b/src/startup_stubs/d3d12_draw.inl @@ -1468,10 +1468,11 @@ IndirectBufferView indirect_table_buffer(Wrapper* self, const std::uint32_t* wor return {}; } const auto placed = placed_buffer_range(device, address, bytes); - if (placed.reject || !placed.alias || (owner && owner != placed.owner)) return {}; + if (placed.reject || !placed.owner || (owner && owner != placed.owner)) return {}; owner = placed.owner; - native = placed.alias; + native = static_cast(owner->own().real); offset = address - reinterpret_cast(owner->own().title_memory); + if (!placed.alias && (!native || !list_copied_gpu_range(self, native, offset, bytes))) return {}; } else if (owner && !owner->own().title_memory) { native = static_cast(owner->own().real); D3D12_HEAP_PROPERTIES props{}; diff --git a/src/startup_stubs/d3d12_xs_device.cpp b/src/startup_stubs/d3d12_xs_device.cpp index c2321f7778..c413b53fa9 100644 --- a/src/startup_stubs/d3d12_xs_device.cpp +++ b/src/startup_stubs/d3d12_xs_device.cpp @@ -1957,6 +1957,8 @@ std::size_t readable_window(u64 address, std::size_t wanted) // Per-list state while recording. struct Pass { + struct CopyRange { ID3D12Resource* resource; u64 offset, bytes; }; + std::vector copied_gpu_ranges; // exact CopyBufferRegion destinations on this recording bool pipeline_real = false; // the bound pipeline has a desktop pipeline bool compute_pipeline = false; ID3D12RootSignature* compute_root = nullptr; // desktop compute root set by slot 33 @@ -2018,6 +2020,38 @@ Pass& pass_of(Wrapper* self) if (!self->own().pass) self->own().pass = new Pass; return *static_cast(self->own().pass); } + +bool indirect_copy_ranges() +{ + static const bool enabled = x2w_local::env_on("X2W_TRANSLATED_INDIRECT_COPY_RANGES"); + return enabled; +} + +bool list_copied_gpu_range(Wrapper* self, ID3D12Resource* resource, u64 offset, u64 bytes) +{ + if (!indirect_copy_ranges()) return false; + const auto& ranges = pass_of(self).copied_gpu_ranges; + return std::any_of(ranges.begin(), ranges.end(), [&](const Pass::CopyRange& range) { + return range.resource == resource && offset >= range.offset && bytes <= range.bytes && + offset - range.offset <= range.bytes - bytes; + }); +} + +void note_copy_gpu_range(Wrapper* self, ID3D12Resource* resource, u64 offset, u64 bytes, bool authoritative) +{ + if (!indirect_copy_ranges()) return; + auto& ranges = pass_of(self).copied_gpu_ranges; + ranges.erase(std::remove_if(ranges.begin(), ranges.end(), [&](const Pass::CopyRange& range) { + if (range.resource != resource) return false; + return range.offset <= offset ? offset - range.offset < range.bytes : range.offset - offset < bytes; + }), ranges.end()); + if (authoritative && ranges.size() < 64) { + try { ranges.push_back({resource, offset, bytes}); } + catch (const std::bad_alloc&) { return; } + static LONG reports; + if (first_calls(reports, 16)) log("x2w-render recorded GPU buffer copy range: offset 0x%llx, %llu bytes", offset, bytes); + } +} // Desktop resources rest in COMMON between lists; a list moves them as it needs and back at Close. void require_state(Wrapper* self, ID3D12Resource* resource, D3D12_RESOURCE_STATES state) { diff --git a/src/startup_stubs/list_copy.inl b/src/startup_stubs/list_copy.inl index b144d04e9b..2e82c5bbdb 100644 --- a/src/startup_stubs/list_copy.inl +++ b/src/startup_stubs/list_copy.inl @@ -155,6 +155,24 @@ x2w_startup::CopyRefusal check_roles_and_sync(Wrapper* self, const CopyEndpoint& return x2w_startup::CopyRefusal::none; } +// A covered range in a copied placement is useful only if the recorded copy read an authoritative source. +bool copy_source_authoritative(Wrapper* self, const CopyEndpoint& from, u64 offset, u64 bytes) +{ + if (!from.wrapper || !InterlockedCompareExchange(&from.wrapper->own().refs, 0, 0)) return false; + const auto* info = resource_info(from.wrapper); + if (!info || info->initial_state != D3D12_RESOURCE_STATE_COMMON) return false; + x2w_startup::ComPtr device; + if (FAILED(from.resource->GetDevice(IID_PPV_ARGS(device.GetAddressOf()))) || device.Get() != device_of(self->own().list_device)) + return false; + if (!from.wrapper->own().title_memory) return true; + if (!info->placement_device || info->placement_device != self->own().list_device) return false; + const auto address = reinterpret_cast(from.wrapper->own().title_memory); + if (offset > UINT64_MAX - address) return false; + const auto placed = placed_buffer_range(self->own().list_device, address + offset, bytes); + if (placed.reject || placed.owner != from.wrapper) return false; + return placed.alias || list_copied_gpu_range(self, from.resource, offset, bytes); +} + // List slot 15, CopyBufferRegion(destination, destination offset, source, source offset, bytes). void __stdcall list_copy_buffer_region(Wrapper* self, u64 destination, u64 destination_offset, u64 source, u64 source_offset, u64 bytes) @@ -168,13 +186,21 @@ void __stdcall list_copy_buffer_region(Wrapper* self, u64 destination, u64 desti auto refusal = x2w_startup::check_copy_buffer_region(to.resource ? &to_desc : nullptr, destination_offset, from.resource ? &from_desc : nullptr, source_offset, bytes, to.resource == from.resource); - if (refusal == x2w_startup::CopyRefusal::none) refusal = check_roles_and_sync(self, to, from, true); + if (refusal == x2w_startup::CopyRefusal::none) refusal = check_endpoint_roles(to, from); + const bool authoritative = refusal == x2w_startup::CopyRefusal::none && indirect_copy_ranges() && + copy_source_authoritative(self, from, source_offset, bytes); + if (refusal == x2w_startup::CopyRefusal::none && !authoritative && !sync_title_source(self, from)) + refusal = x2w_startup::CopyRefusal::title_backed_source; if (refusal != x2w_startup::CopyRefusal::none) return refuse_copy("CopyBufferRegion", refusal); require_copy_state(self, from.resource, D3D12_RESOURCE_STATE_COPY_SOURCE); require_copy_state(self, to.resource, D3D12_RESOURCE_STATE_COPY_DEST); static_cast(self->own().real) ->CopyBufferRegion(to.resource, destination_offset, from.resource, source_offset, bytes); - mark_gpu_written(self, to); + if (indirect_copy_ranges()) { + const auto* info = to.wrapper ? resource_info(to.wrapper) : nullptr; + note_copy_gpu_range(self, to.resource, destination_offset, bytes, authoritative && info && + info->placement == Placement::copied_buffer && info->placement_device == self->own().list_device); + } InterlockedIncrement(&list_buffer_copies); } @@ -194,7 +220,9 @@ void __stdcall list_copy_resource(Wrapper* self, u64 destination, u64 source) require_copy_state(self, from.resource, D3D12_RESOURCE_STATE_COPY_SOURCE); require_copy_state(self, to.resource, D3D12_RESOURCE_STATE_COPY_DEST); static_cast(self->own().real)->CopyResource(to.resource, from.resource); - mark_gpu_written(self, to); + if (to_desc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) + note_copy_gpu_range(self, to.resource, 0, to_desc.Width, false); + else mark_gpu_written(self, to); InterlockedIncrement(&list_resource_copies); } diff --git a/tests/startup_indirect_draw_indexed.cpp b/tests/startup_indirect_draw_indexed.cpp index 6671290416..564f0c3c1f 100644 --- a/tests/startup_indirect_draw_indexed.cpp +++ b/tests/startup_indirect_draw_indexed.cpp @@ -31,6 +31,7 @@ constexpr Words initial{0xa5a5a5a5, 0, 0, 0, 0, 0, 0x5a5a5a5a}; constexpr std::array indices{99, 99, 99, 0, 1, 2, 3, 4, 5, 99}; constexpr std::array wide_indices{99, 99, 99, 0, 1, 2, 3, 4, 5, 99}; constexpr UINT argument_offset = sizeof(std::uint32_t); +constexpr UINT64 replay_copy_offset = 0xbfffa0, replay_copy_bytes = 0x44; constexpr char shader[] = R"( RWByteAddressBuffer data : register(u0); @@ -63,6 +64,17 @@ void write_buffer_colour() { data.Store(32, 0xff0000ffu); } +[numthreads(1, 1, 1)] +void write_replay_colour() { + data.Store(0, 0xff00ff00u); + data.Store(4, 0xff00ff00u); + data.Store4(0xbfffa0, uint4(0xff00ff00u, 0xff0000ffu, 0, 0)); + data.Store4(0xbfffb0, uint4(0, 0, 0, 0)); + data.Store4(0xbfffc0, uint4(0, 0, 0, 0)); + data.Store4(0xbfffd0, uint4(0, 0, 0, 0)); + data.Store(0xbfffe0, 0); +} + [numthreads(1, 1, 1)] void write_one_mesh_group() { data.Store3(4, uint3(1, 1, 1)); @@ -316,32 +328,39 @@ void submit(ID3D12Device* device, ID3D12GraphicsCommandList* list) } enum class Refusal { none, invalid_index, short_argument, missing_viewport, wrong_root, missing_texture, start_vertex, - insufficient_table_range, copied_table_buffer, upload_range_crossing }; + insufficient_table_range, copied_table_buffer, upload_range_crossing, unproven_copy }; enum class DrawKind { indexed, vertices, mesh }; +ComPtr make_gpu_table_buffer(ID3D12Device* guest, UINT64 bytes) +{ + const D3D12_HEAP_PROPERTIES props{D3D12_HEAP_TYPE_DEFAULT}; + const D3D12_RESOURCE_DESC desc{D3D12_RESOURCE_DIMENSION_BUFFER, 0, bytes, 1, 1, 1, DXGI_FORMAT_UNKNOWN, {1, 0}, + D3D12_TEXTURE_LAYOUT_ROW_MAJOR, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS}; + using Create = HRESULT (WINAPI*)(IUnknown*, const D3D12_HEAP_PROPERTIES*, UINT, const D3D12_RESOURCE_DESC*, + UINT, const void*, void*, UINT, const void*, REFIID, void**); + ComPtr result; + check(slot(guest, 127)(guest, &props, 0, &desc, D3D12_RESOURCE_STATE_COMMON, nullptr, nullptr, + 0, nullptr, __uuidof(ID3D12Resource), reinterpret_cast(result.GetAddressOf())), "create GPU table buffer"); + return result; +} + struct TranslatedDrawFixture { TranslatedDrawFixture(ID3D12Device* guest, std::uint32_t colour, ID3D12Device* desktop = nullptr, - bool short_view = false, bool copied = false) + bool short_view = false, bool copied = false, bool replay = false) : wrong_root(create_root(guest, {0, nullptr, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE})), backing(VirtualAlloc(nullptr, 65536, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE)) { if (!backing) throw std::bad_alloc(); if (desktop && !copied) { - const D3D12_HEAP_PROPERTIES props{D3D12_HEAP_TYPE_DEFAULT}; - const D3D12_RESOURCE_DESC desc{D3D12_RESOURCE_DIMENSION_BUFFER, 0, 64, 1, 1, 1, DXGI_FORMAT_UNKNOWN, {1, 0}, - D3D12_TEXTURE_LAYOUT_ROW_MAJOR, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS}; - using Create = HRESULT (WINAPI*)(IUnknown*, const D3D12_HEAP_PROPERTIES*, UINT, const D3D12_RESOURCE_DESC*, - UINT, const void*, void*, UINT, const void*, REFIID, void**); - check(slot(guest, 127)(guest, &props, 0, &desc, D3D12_RESOURCE_STATE_COMMON, nullptr, nullptr, - 0, nullptr, __uuidof(ID3D12Resource), reinterpret_cast(sampled.GetAddressOf())), "create GPU table buffer"); + sampled = make_gpu_table_buffer(guest, 64); } else { const D3D12_RESOURCE_DESC desc = copied ? - D3D12_RESOURCE_DESC{D3D12_RESOURCE_DIMENSION_BUFFER, 0, 64, 1, 1, 1, DXGI_FORMAT_UNKNOWN, {1, 0}, + D3D12_RESOURCE_DESC{D3D12_RESOURCE_DIMENSION_BUFFER, 0, replay ? replay_copy_bytes : 64u, 1, 1, 1, DXGI_FORMAT_UNKNOWN, {1, 0}, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS} : D3D12_RESOURCE_DESC{D3D12_RESOURCE_DIMENSION_TEXTURE2D, 0, 1, 1, 1, 1, format, {1, 0}, D3D12_TEXTURE_LAYOUT_UNKNOWN, D3D12_RESOURCE_FLAG_NONE}; auto* address = static_cast(backing.get()) + (copied ? 16 : 0); - std::memcpy(address + (copied ? 32 : 0), &colour, sizeof(colour)); + std::memcpy(address + (replay ? 4 : copied ? 32 : 0), &colour, sizeof(colour)); using Place = HRESULT (WINAPI*)(IUnknown*, void*, const D3D12_RESOURCE_DESC*, UINT, const void*, REFIID, void**); check(slot(guest, 133)(guest, address, &desc, D3D12_RESOURCE_STATE_COMMON, nullptr, __uuidof(ID3D12Resource), reinterpret_cast(sampled.GetAddressOf())), "place sampled resource"); @@ -363,9 +382,9 @@ struct TranslatedDrawFixture { if (desktop) { srv.Format = DXGI_FORMAT_UNKNOWN; srv.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; - srv.Buffer.FirstElement = 1; - srv.Buffer.NumElements = short_view ? 1 : 2; - srv.Buffer.StructureByteStride = 16; + srv.Buffer.FirstElement = replay ? 0 : 1; + srv.Buffer.NumElements = replay ? static_cast(replay_copy_bytes / 4) : short_view ? 1 : 2; + srv.Buffer.StructureByteStride = replay ? 4 : 16; } else { srv.Format = format; srv.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; @@ -389,6 +408,14 @@ struct TranslatedDrawFixture { UINT64 gpu = 0; }; +struct ReplayCopy { + ID3D12Resource* producer; + ID3D12Resource* native; + ID3D12PipelineState* writer; + UINT64 bytes; + bool uncertified_overwrite = false; +}; + constexpr UINT command_stride(DrawKind kind) { switch (kind) { @@ -409,7 +436,7 @@ bool supports_mesh(ID3D12Device* device) bool run(ID3D12Device* device, ID3D12Device* guest, ID3D12RootSignature* writer_root, ID3D12PipelineState* writer, ID3D12RootSignature* graphics_root, IUnknown* graphics, ID3D12CommandSignature* signature, DrawKind kind, bool draw_right, Refusal refusal, const char* label, - const TranslatedDrawFixture* translated = nullptr, bool upload_table = false) + const TranslatedDrawFixture* translated = nullptr, bool upload_table = false, const ReplayCopy* replay = nullptr) { const bool indexed = kind == DrawKind::indexed; const bool mesh = kind == DrawKind::mesh; @@ -482,6 +509,18 @@ bool run(ID3D12Device* device, ID3D12Device* guest, ID3D12RootSignature* writer_ list->CopyBufferRegion(arg_readback.Get(), 0, arguments.native.Get(), 0, sizeof(initial)); // The wrapper owns the subsequent COMMON -> INDIRECT_ARGUMENT transition. transition(list, arguments.native.Get(), D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_COMMON); + if (replay) { + transition(list, replay->native, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); + list->SetPipelineState(replay->writer); + list->SetComputeRootSignature(writer_root); + list->SetComputeRootUnorderedAccessView(0, replay->native->GetGPUVirtualAddress()); + list->Dispatch(1, 1, 1); + transition(list, replay->native, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COMMON); + using Copy = void (WINAPI*)(IUnknown*, IUnknown*, UINT64, IUnknown*, UINT64, UINT64); + slot(wrapped, 15)(wrapped, translated->sampled.Get(), 0, replay->producer, replay_copy_offset, replay->bytes); + if (replay->uncertified_overwrite) + slot(wrapped, 15)(wrapped, translated->sampled.Get(), 0, replay->native, 0, 4); + } if (translated && translated->gpu_buffer && translated->buffer_writer) { auto* table_resource = translated->gpu_buffer.Get(); transition(list, table_resource, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); @@ -637,7 +676,9 @@ std::string indirect_line(ID3D12Device* guest, const std::wstring& log_path) int main(int argc, char** argv) try { DrawKind kind = DrawKind::indexed; - const bool translated = argc == 3 && std::strcmp(argv[2], "translated") == 0; + const bool copy_on = argc == 3 && std::strcmp(argv[2], "copy-provenance") == 0; + const bool copy_off = argc == 3 && std::strcmp(argv[2], "copy-provenance-off") == 0; + const bool translated = copy_on || copy_off || (argc == 3 && std::strcmp(argv[2], "translated") == 0); // "count-control" is the negative control: it expects one forwarded call too many. const bool count_control = argc == 3 && std::strcmp(argv[2], "count-control") == 0; if (translated || (argc == 3 && std::strcmp(argv[2], "draw") == 0)) kind = DrawKind::vertices; @@ -712,6 +753,8 @@ int main(int argc, char** argv) try std::filesystem::create_directory(cache); check(SetEnvironmentVariableW(L"X2W_SHADER_CACHE", cache.c_str()) ? S_OK : E_FAIL, "set fixture cache"); check(SetEnvironmentVariableA("X2W_TRANSLATED_INDIRECT_DRAW", "1") ? S_OK : E_FAIL, "enable fixture path"); + check(SetEnvironmentVariableA("X2W_TRANSLATED_INDIRECT_COPY_RANGES", copy_on ? "1" : "0") ? S_OK : E_FAIL, + "set copy-range provenance control"); const D3D12_DESCRIPTOR_RANGE range{D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 1, 0, 0, 0}; D3D12_ROOT_PARAMETER table{}; table.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; @@ -769,6 +812,29 @@ int main(int argc, char** argv) try } else { std::puts("deferred guest root capability unavailable"); } + if (ok && (copy_on || copy_off)) { + const TranslatedDrawFixture copied(guest.Get(), green, device.Get(), false, true, true); + const auto source = make_gpu_table_buffer(guest.Get(), replay_copy_offset + replay_copy_bytes); + const auto native = native_object(device.Get(), guest.Get(), source.Get()); + const auto replay_writer = writer_pipeline(device.Get(), writer.Get(), "write_replay_colour"); + const ReplayCopy complete{source.Get(), native.Get(), replay_writer.Get(), replay_copy_bytes}; + const ReplayCopy partial{source.Get(), native.Get(), replay_writer.Get(), replay_copy_bytes - 4}; + const ReplayCopy overwritten{source.Get(), native.Get(), replay_writer.Get(), replay_copy_bytes, true}; + const auto draw = [&](const ReplayCopy* copy, Refusal refusal, const char* label) { + return run(device.Get(), guest.Get(), writer.Get(), producer.Get(), title_root.Get(), buffer_pso.Get(), signature.Get(), + DrawKind::vertices, false, refusal, label, &copied, false, copy); + }; + ok = draw(&complete, copy_on ? Refusal::none : Refusal::unproven_copy, "complete 68-byte GPU copy") && + draw(nullptr, Refusal::unproven_copy, "new recording cannot reuse the previous GPU copy proof") && + draw(&partial, Refusal::unproven_copy, "64-byte copy cannot authorize the 68-byte view") && + draw(&overwritten, Refusal::unproven_copy, "untracked overlap invalidates the prior copy range"); + std::uint32_t title_word = 0; + std::memcpy(&title_word, static_cast(copied.backing.get()) + 20, sizeof(title_word)); + if (title_word != green) { + std::fprintf(stderr, "title-side green sentinel changed to %08x\n", title_word); + return 1; + } + } if (ok) std::filesystem::remove_all(cache); return ok && (!info || !info->GetNumStoredMessages()) ? 0 : 1; }