D3D12: Texture2D/3D/Cube accessed inside a single SRV descriptor heap ?

Started by
11 comments, last by Adam Miles 8 years, 2 months ago
Off-Topic: Your data_cache (used to cache your textures) looks inefficient:

std::list <std::tuple<u64, u32, u32> > m_protected_ranges;

It appears they are not sorted. If so, consider using a vector and remove elements using swap and pop trick. MUCH faster:


/** Used for efficient removal in std::vector and std::deque (like an std::list)
    However it assumes the order of elements in container is not important or
    something external to the container holds the index of an element in it
    (but still should be kept deterministically across machines)
    Basically it swaps the iterator with the last iterator, and pops back
    Returns the next iterator
*/
template<typename T>
typename T::iterator efficientVectorRemove( T& container, typename T::iterator& iterator )
{
    const size_t idx = iterator - container.begin();
    *iterator = container.back();
    container.pop_back();

    return container.begin() + idx;
}

nextElement = efficientVectorRemove( container, elementToRemove );
//remember that container.end() has been updated now.
As for the unordered_map; if profiling shows you rarely insert or remove elements from it, consider using a sorted vector instead (which makes memory contiguous).
Advertisement

How does descriptor copying work in regards to command list synchronization? When you submit a list, it runs asynchronously, but you can modify the descriptor heap it's using immediately afterwords. Do the current contents of the descriptor heap get copied when you set them to a command list? Or does this create a race condition and you need to use fences or something to track when it's safe to modify descriptors?

How does descriptor copying work in regards to command list synchronization? When you submit a list, it runs asynchronously, but you can modify the descriptor heap it's using immediately afterwords. Do the current contents of the descriptor heap get copied when you set them to a command list? Or does this create a race condition and you need to use fences or something to track when it's safe to modify descriptors?

The latter. You are responsible for not modifying the relevant areas of the shader-visible descriptor heap until all command lists using that range are done executing. And yes, you can use a fence to determine when that has occurred.

Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group

This topic is closed to new replies.

Advertisement