Skip to content

DX12: PageGuardManager may fail to track pages of overlapping placed resources #2853

@davidd-lunarg

Description

@davidd-lunarg

When memory is mapped in DX12, its pointer is used as the identifier for the memory.

In D3D12CaptureManager::PostProcess_ID3D12Resource_Map:
manager->AddTrackedMemory(reinterpret_cast<uint64_t>(mapped_subresource.data),

In PageGuardManager::AddTrackedMemory:

auto entry =
    memory_info_.emplace(std::piecewise_construct,
                     std::forward_as_tuple(memory_id),
                     std::forward_as_tuple(mapped_memory,
                                           mapped_range,
                                           shadow_memory,
                                           shadow_size,
                                           aligned_address,
                                           aligned_offset,
                                           total_pages,
                                           last_segment_size,
                                           start_address,
                                           static_cast<const uint8_t*>(start_address) + mapped_range,
                                           use_write_watch,
                                           shadow_memory_handle == kNullShadowHandle));

If two overlapping resources are created and mapped at the same resource (with CreatePlacedResource), the second call to AddTrackedMemory does not update the memory_info_ map. And if the second resource mapped is larger than the first resource, the additional memory pages it covers won't be processed in PageGuardManager::LoadActiveWriteStates because the dirty pages are retrieved based on the information stored in the memory_info_ map:

    if (GetWriteWatch(WRITE_WATCH_FLAG_RESET,
                      memory_info->aligned_address,
                      memory_info->mapped_range + memory_info->aligned_offset,
                      modified_addresses,
                      &modified_count,
                      &granularity) == 0)

This is a potential issue identified by code inspection. I am not aware of a real world use case that encounters this problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    captureIssue with captured3d12Issue with D3D 12 support

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions