mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-21 22:54:16 +01:00
[dxvk] Introduce DxvkResourceMemoryInfo
And replace the old sparse thing.
This commit is contained in:
parent
bbd2461c8f
commit
af4a2f7973
@ -1005,21 +1005,21 @@ namespace dxvk {
|
|||||||
|
|
||||||
void bindBufferMemory(
|
void bindBufferMemory(
|
||||||
const DxvkSparseBufferBindKey& key,
|
const DxvkSparseBufferBindKey& key,
|
||||||
const DxvkSparsePageHandle& memory) {
|
const DxvkResourceMemoryInfo& memory) {
|
||||||
getSparseBindSubmission().bindBufferMemory(key, memory);
|
getSparseBindSubmission().bindBufferMemory(key, memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void bindImageMemory(
|
void bindImageMemory(
|
||||||
const DxvkSparseImageBindKey& key,
|
const DxvkSparseImageBindKey& key,
|
||||||
const DxvkSparsePageHandle& memory) {
|
const DxvkResourceMemoryInfo& memory) {
|
||||||
getSparseBindSubmission().bindImageMemory(key, memory);
|
getSparseBindSubmission().bindImageMemory(key, memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void bindImageOpaqueMemory(
|
void bindImageOpaqueMemory(
|
||||||
const DxvkSparseImageOpaqueBindKey& key,
|
const DxvkSparseImageOpaqueBindKey& key,
|
||||||
const DxvkSparsePageHandle& memory) {
|
const DxvkResourceMemoryInfo& memory) {
|
||||||
getSparseBindSubmission().bindImageOpaqueMemory(key, memory);
|
getSparseBindSubmission().bindImageOpaqueMemory(key, memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1559,10 +1559,10 @@ namespace dxvk {
|
|||||||
key.size = r.imageMipTailSize;
|
key.size = r.imageMipTailSize;
|
||||||
key.flags = VK_SPARSE_MEMORY_BIND_METADATA_BIT;
|
key.flags = VK_SPARSE_MEMORY_BIND_METADATA_BIT;
|
||||||
|
|
||||||
DxvkSparsePageHandle page;
|
DxvkResourceMemoryInfo page;
|
||||||
page.memory = imageMemory;
|
page.memory = imageMemory;
|
||||||
page.offset = imageOffset;
|
page.offset = imageOffset;
|
||||||
page.length = r.imageMipTailSize;
|
page.size = r.imageMipTailSize;
|
||||||
|
|
||||||
m_cmd->bindImageOpaqueMemory(key, page);
|
m_cmd->bindImageOpaqueMemory(key, page);
|
||||||
|
|
||||||
|
@ -388,6 +388,19 @@ namespace dxvk {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Memory properties
|
||||||
|
*/
|
||||||
|
struct DxvkResourceMemoryInfo {
|
||||||
|
/// Vulkan memory handle
|
||||||
|
VkDeviceMemory memory = VK_NULL_HANDLE;
|
||||||
|
/// Offset into memory object
|
||||||
|
VkDeviceSize offset = 0u;
|
||||||
|
/// Size of memory range
|
||||||
|
VkDeviceSize size = 0u;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Buffer properties
|
* \brief Buffer properties
|
||||||
*/
|
*/
|
||||||
@ -521,6 +534,18 @@ namespace dxvk {
|
|||||||
return m_mapPtr;
|
return m_mapPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Queries memory info
|
||||||
|
* \returns Memory info
|
||||||
|
*/
|
||||||
|
DxvkResourceMemoryInfo getMemoryInfo() const {
|
||||||
|
DxvkResourceMemoryInfo result = { };
|
||||||
|
result.memory = m_memory;
|
||||||
|
result.offset = m_address & DxvkPageAllocator::ChunkAddressMask;
|
||||||
|
result.size = m_size;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Queries buffer info
|
* \brief Queries buffer info
|
||||||
* \returns Buffer info
|
* \returns Buffer info
|
||||||
|
@ -446,21 +446,21 @@ namespace dxvk {
|
|||||||
|
|
||||||
void DxvkSparseBindSubmission::bindBufferMemory(
|
void DxvkSparseBindSubmission::bindBufferMemory(
|
||||||
const DxvkSparseBufferBindKey& key,
|
const DxvkSparseBufferBindKey& key,
|
||||||
const DxvkSparsePageHandle& memory) {
|
const DxvkResourceMemoryInfo& memory) {
|
||||||
m_bufferBinds.insert_or_assign(key, memory);
|
m_bufferBinds.insert_or_assign(key, memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkSparseBindSubmission::bindImageMemory(
|
void DxvkSparseBindSubmission::bindImageMemory(
|
||||||
const DxvkSparseImageBindKey& key,
|
const DxvkSparseImageBindKey& key,
|
||||||
const DxvkSparsePageHandle& memory) {
|
const DxvkResourceMemoryInfo& memory) {
|
||||||
m_imageBinds.insert_or_assign(key, memory);
|
m_imageBinds.insert_or_assign(key, memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkSparseBindSubmission::bindImageOpaqueMemory(
|
void DxvkSparseBindSubmission::bindImageOpaqueMemory(
|
||||||
const DxvkSparseImageOpaqueBindKey& key,
|
const DxvkSparseImageOpaqueBindKey& key,
|
||||||
const DxvkSparsePageHandle& memory) {
|
const DxvkResourceMemoryInfo& memory) {
|
||||||
m_imageOpaqueBinds.insert_or_assign(key, memory);
|
m_imageOpaqueBinds.insert_or_assign(key, memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,8 +560,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
bool DxvkSparseBindSubmission::tryMergeImageBind(
|
bool DxvkSparseBindSubmission::tryMergeImageBind(
|
||||||
std::pair<DxvkSparseImageBindKey, DxvkSparsePageHandle>& oldBind,
|
std::pair<DxvkSparseImageBindKey, DxvkResourceMemoryInfo>& oldBind,
|
||||||
const std::pair<DxvkSparseImageBindKey, DxvkSparsePageHandle>& newBind) {
|
const std::pair<DxvkSparseImageBindKey, DxvkResourceMemoryInfo>& newBind) {
|
||||||
if (oldBind.first.image != newBind.first.image
|
if (oldBind.first.image != newBind.first.image
|
||||||
|| oldBind.first.subresource.aspectMask != newBind.first.subresource.aspectMask
|
|| oldBind.first.subresource.aspectMask != newBind.first.subresource.aspectMask
|
||||||
|| oldBind.first.subresource.mipLevel != newBind.first.subresource.mipLevel
|
|| oldBind.first.subresource.mipLevel != newBind.first.subresource.mipLevel
|
||||||
@ -572,7 +572,7 @@ namespace dxvk {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (oldBind.second.memory) {
|
if (oldBind.second.memory) {
|
||||||
if (oldBind.second.offset + oldBind.second.length != newBind.second.offset)
|
if (oldBind.second.offset + oldBind.second.size != newBind.second.offset)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -604,7 +604,7 @@ namespace dxvk {
|
|||||||
oldBind.first.extent.depth += delta.depth;
|
oldBind.first.extent.depth += delta.depth;
|
||||||
|
|
||||||
if (oldBind.second.memory)
|
if (oldBind.second.memory)
|
||||||
oldBind.second.length += newBind.second.length;
|
oldBind.second.size += newBind.second.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
return canMerge;
|
return canMerge;
|
||||||
@ -641,14 +641,14 @@ namespace dxvk {
|
|||||||
|
|
||||||
void DxvkSparseBindSubmission::processImageBinds(
|
void DxvkSparseBindSubmission::processImageBinds(
|
||||||
DxvkSparseImageBindArrays& image) {
|
DxvkSparseImageBindArrays& image) {
|
||||||
std::vector<std::pair<DxvkSparseImageBindKey, DxvkSparsePageHandle>> binds;
|
std::vector<std::pair<DxvkSparseImageBindKey, DxvkResourceMemoryInfo>> binds;
|
||||||
binds.reserve(m_imageBinds.size());
|
binds.reserve(m_imageBinds.size());
|
||||||
|
|
||||||
for (const auto& e : m_imageBinds) {
|
for (const auto& e : m_imageBinds) {
|
||||||
std::pair<DxvkSparseImageBindKey, DxvkSparsePageHandle> newBind = e;
|
std::pair<DxvkSparseImageBindKey, DxvkResourceMemoryInfo> newBind = e;
|
||||||
|
|
||||||
while (!binds.empty()) {
|
while (!binds.empty()) {
|
||||||
std::pair<DxvkSparseImageBindKey, DxvkSparsePageHandle> oldBind = binds.back();
|
std::pair<DxvkSparseImageBindKey, DxvkResourceMemoryInfo> oldBind = binds.back();
|
||||||
|
|
||||||
if (!tryMergeImageBind(oldBind, newBind))
|
if (!tryMergeImageBind(oldBind, newBind))
|
||||||
break;
|
break;
|
||||||
|
@ -18,16 +18,6 @@ namespace dxvk {
|
|||||||
|
|
||||||
constexpr static VkDeviceSize SparseMemoryPageSize = 1ull << 16;
|
constexpr static VkDeviceSize SparseMemoryPageSize = 1ull << 16;
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Sparse page handle
|
|
||||||
*/
|
|
||||||
struct DxvkSparsePageHandle {
|
|
||||||
VkDeviceMemory memory;
|
|
||||||
VkDeviceSize offset;
|
|
||||||
VkDeviceSize length;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Buffer info for sparse page
|
* \brief Buffer info for sparse page
|
||||||
*
|
*
|
||||||
@ -182,11 +172,11 @@ namespace dxvk {
|
|||||||
* \brief Queries memory handle
|
* \brief Queries memory handle
|
||||||
* \returns Memory information
|
* \returns Memory information
|
||||||
*/
|
*/
|
||||||
DxvkSparsePageHandle getHandle() const {
|
DxvkResourceMemoryInfo getHandle() const {
|
||||||
DxvkSparsePageHandle result;
|
DxvkResourceMemoryInfo result;
|
||||||
result.memory = m_memory.memory();
|
result.memory = m_memory.memory();
|
||||||
result.offset = m_memory.offset();
|
result.offset = m_memory.offset();
|
||||||
result.length = m_memory.length();
|
result.size = m_memory.length();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,9 +213,9 @@ namespace dxvk {
|
|||||||
* \brief Queries memory handle
|
* \brief Queries memory handle
|
||||||
* \returns Memory information
|
* \returns Memory information
|
||||||
*/
|
*/
|
||||||
DxvkSparsePageHandle getHandle() const {
|
DxvkResourceMemoryInfo getHandle() const {
|
||||||
if (m_page == nullptr)
|
if (m_page == nullptr)
|
||||||
return DxvkSparsePageHandle();
|
return DxvkResourceMemoryInfo();
|
||||||
|
|
||||||
return m_page->getHandle();
|
return m_page->getHandle();
|
||||||
}
|
}
|
||||||
@ -670,7 +660,7 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
void bindBufferMemory(
|
void bindBufferMemory(
|
||||||
const DxvkSparseBufferBindKey& key,
|
const DxvkSparseBufferBindKey& key,
|
||||||
const DxvkSparsePageHandle& memory);
|
const DxvkResourceMemoryInfo& memory);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Adds an image memory bind
|
* \brief Adds an image memory bind
|
||||||
@ -680,7 +670,7 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
void bindImageMemory(
|
void bindImageMemory(
|
||||||
const DxvkSparseImageBindKey& key,
|
const DxvkSparseImageBindKey& key,
|
||||||
const DxvkSparsePageHandle& memory);
|
const DxvkResourceMemoryInfo& memory);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Adds an opaque image memory bind
|
* \brief Adds an opaque image memory bind
|
||||||
@ -690,7 +680,7 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
void bindImageOpaqueMemory(
|
void bindImageOpaqueMemory(
|
||||||
const DxvkSparseImageOpaqueBindKey& key,
|
const DxvkSparseImageOpaqueBindKey& key,
|
||||||
const DxvkSparsePageHandle& memory);
|
const DxvkResourceMemoryInfo& memory);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Submits sparse binding operation
|
* \brief Submits sparse binding operation
|
||||||
@ -720,17 +710,17 @@ namespace dxvk {
|
|||||||
std::vector<uint64_t> m_signalSemaphoreValues;
|
std::vector<uint64_t> m_signalSemaphoreValues;
|
||||||
std::vector<VkSemaphore> m_signalSemaphores;
|
std::vector<VkSemaphore> m_signalSemaphores;
|
||||||
|
|
||||||
std::map<DxvkSparseBufferBindKey, DxvkSparsePageHandle> m_bufferBinds;
|
std::map<DxvkSparseBufferBindKey, DxvkResourceMemoryInfo> m_bufferBinds;
|
||||||
std::map<DxvkSparseImageBindKey, DxvkSparsePageHandle> m_imageBinds;
|
std::map<DxvkSparseImageBindKey, DxvkResourceMemoryInfo> m_imageBinds;
|
||||||
std::map<DxvkSparseImageOpaqueBindKey, DxvkSparsePageHandle> m_imageOpaqueBinds;
|
std::map<DxvkSparseImageOpaqueBindKey, DxvkResourceMemoryInfo> m_imageOpaqueBinds;
|
||||||
|
|
||||||
static bool tryMergeMemoryBind(
|
static bool tryMergeMemoryBind(
|
||||||
VkSparseMemoryBind& oldBind,
|
VkSparseMemoryBind& oldBind,
|
||||||
const VkSparseMemoryBind& newBind);
|
const VkSparseMemoryBind& newBind);
|
||||||
|
|
||||||
static bool tryMergeImageBind(
|
static bool tryMergeImageBind(
|
||||||
std::pair<DxvkSparseImageBindKey, DxvkSparsePageHandle>& oldBind,
|
std::pair<DxvkSparseImageBindKey, DxvkResourceMemoryInfo>& oldBind,
|
||||||
const std::pair<DxvkSparseImageBindKey, DxvkSparsePageHandle>& newBind);
|
const std::pair<DxvkSparseImageBindKey, DxvkResourceMemoryInfo>& newBind);
|
||||||
|
|
||||||
void processBufferBinds(
|
void processBufferBinds(
|
||||||
DxvkSparseBufferBindArrays& buffer);
|
DxvkSparseBufferBindArrays& buffer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user