mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-18 02:52:10 +01:00
[d3d11] Introduce methods for dirty region tracking for mapped images
This commit is contained in:
parent
1bed39f266
commit
40ffac72d9
@ -61,6 +61,15 @@ namespace dxvk {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Region
|
||||
*/
|
||||
struct D3D11_COMMON_TEXTURE_REGION {
|
||||
VkOffset3D Offset;
|
||||
VkExtent3D Extent;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief D3D11 common texture object
|
||||
*
|
||||
@ -292,6 +301,72 @@ namespace dxvk {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Adds a dirty region
|
||||
*
|
||||
* This region will be updated on Unmap.
|
||||
* \param [in] Subresource Subresource index
|
||||
* \param [in] Offset Region offset
|
||||
* \param [in] Extent Region extent
|
||||
*/
|
||||
void AddDirtyRegion(UINT Subresource, VkOffset3D Offset, VkExtent3D Extent) {
|
||||
D3D11_COMMON_TEXTURE_REGION region;
|
||||
region.Offset = Offset;
|
||||
region.Extent = Extent;
|
||||
|
||||
if (Subresource < m_buffers.size())
|
||||
m_buffers[Subresource].dirtyRegions.push_back(region);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Clears dirty regions
|
||||
*
|
||||
* Removes all dirty regions from the given subresource.
|
||||
* \param [in] Subresource Subresource index
|
||||
*/
|
||||
void ClearDirtyRegions(UINT Subresource) {
|
||||
if (Subresource < m_buffers.size())
|
||||
m_buffers[Subresource].dirtyRegions.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Counts dirty regions
|
||||
*
|
||||
* \param [in] Subresource Subresource index
|
||||
* \returns Dirty region count
|
||||
*/
|
||||
UINT GetDirtyRegionCount(UINT Subresource) {
|
||||
return (Subresource < m_buffers.size())
|
||||
? UINT(m_buffers[Subresource].dirtyRegions.size())
|
||||
: UINT(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Retrieves dirty regions
|
||||
*
|
||||
* \param [in] Subresource Subresource index
|
||||
* \param [in] Region Region index
|
||||
* \returns Dirty region
|
||||
*/
|
||||
D3D11_COMMON_TEXTURE_REGION GetDirtyRegionCount(UINT Subresource, UINT Region) {
|
||||
return m_buffers[Subresource].dirtyRegions[Region];
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Checks whether or not to track dirty regions
|
||||
*
|
||||
* If this returns true, then any functions that update the
|
||||
* mapped staging buffer must also track dirty regions while
|
||||
* the image is mapped. Otherwise, the entire image is dirty.
|
||||
* \returns \c true if dirty regions must be tracked
|
||||
*/
|
||||
bool NeedsDirtyRegionTracking() const {
|
||||
// Only set this for images where Map can't return a pointer
|
||||
return m_mapMode == D3D11_COMMON_TEXTURE_MAP_MODE_BUFFER
|
||||
&& m_desc.Usage == D3D11_USAGE_DEFAULT
|
||||
&& m_desc.TextureLayout == D3D11_TEXTURE_LAYOUT_UNDEFINED;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Computes pixel offset into mapped buffer
|
||||
*
|
||||
@ -379,6 +454,8 @@ namespace dxvk {
|
||||
struct MappedBuffer {
|
||||
Rc<DxvkBuffer> buffer;
|
||||
DxvkBufferSliceHandle slice;
|
||||
|
||||
std::vector<D3D11_COMMON_TEXTURE_REGION> dirtyRegions;
|
||||
};
|
||||
|
||||
struct MappedInfo {
|
||||
|
Loading…
x
Reference in New Issue
Block a user