| 1517 | } |
| 1518 | |
| 1519 | void DescriptorViewer::OnEventChanged(uint32_t eventId) |
| 1520 | { |
| 1521 | // each time, re-fetch the descriptors to get up to date contents |
| 1522 | if(m_DescriptorStore.resourceId != ResourceId() && m_DescriptorStore.descriptorByteSize != 0) |
| 1523 | { |
| 1524 | m_Ctx.Replay().AsyncInvoke([this](IReplayController *r) { |
| 1525 | uint32_t descSize = m_DescriptorStore.descriptorByteSize; |
| 1526 | |
| 1527 | rdcarray<DescriptorRange> ranges; |
| 1528 | ranges.resize(1); |
| 1529 | ranges[0].count = m_DescriptorStore.descriptorCount; |
| 1530 | ranges[0].descriptorSize = descSize; |
| 1531 | ranges[0].offset = m_DescriptorStore.firstDescriptorOffset; |
| 1532 | // assume this descriptor store knows its type information and can interpret typeless descriptors |
| 1533 | ranges[0].type = DescriptorType::Unknown; |
| 1534 | |
| 1535 | rdcarray<Descriptor> descriptors = r->GetDescriptors(m_DescriptorStore.resourceId, ranges); |
| 1536 | rdcarray<DescriptorLogicalLocation> locations = |
| 1537 | r->GetDescriptorLocations(m_DescriptorStore.resourceId, ranges); |
| 1538 | |
| 1539 | // fetch only sampler descriptors that we need |
| 1540 | |
| 1541 | rdcarray<uint32_t> descriptorToSamplerLookup; |
| 1542 | descriptorToSamplerLookup.fill(descriptors.size(), ~0u); |
| 1543 | |
| 1544 | ranges.clear(); |
| 1545 | |
| 1546 | uint32_t idx = 0; |
| 1547 | for(size_t i = 0; i < descriptors.size(); i++) |
| 1548 | { |
| 1549 | if(descriptors[i].type == DescriptorType::Sampler || |
| 1550 | descriptors[i].type == DescriptorType::ImageSampler) |
| 1551 | { |
| 1552 | descriptorToSamplerLookup[i] = idx; |
| 1553 | idx++; |
| 1554 | |
| 1555 | // combine contiguous ranges |
| 1556 | if(!ranges.empty() && |
| 1557 | ranges.back().offset + ranges.back().count * descSize == i * descSize && |
| 1558 | ranges.back().type == descriptors[i].type) |
| 1559 | { |
| 1560 | ranges.back().count++; |
| 1561 | } |
| 1562 | else |
| 1563 | { |
| 1564 | DescriptorRange range; |
| 1565 | range.offset = m_DescriptorStore.firstDescriptorOffset + uint32_t(i * descSize); |
| 1566 | range.descriptorSize = descSize; |
| 1567 | range.count = 1; |
| 1568 | range.type = descriptors[i].type; |
| 1569 | ranges.push_back(range); |
| 1570 | } |
| 1571 | } |
| 1572 | } |
| 1573 | |
| 1574 | rdcarray<SamplerDescriptor> samplerDescriptors = |
| 1575 | r->GetSamplerDescriptors(m_DescriptorStore.resourceId, ranges); |
| 1576 |
nothing calls this directly
no test coverage detected