1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-14 18:23:52 +01:00
dxvk/src/util/com/com_private_data.h

106 lines
2.3 KiB
C
Raw Normal View History

2017-10-11 03:09:04 +02:00
#pragma once
#include <vector>
#include "com_include.h"
2017-10-11 03:09:04 +02:00
namespace dxvk {
/**
* \brief Data entry for private storage
* Stores a single private storage item.
*/
class ComPrivateDataEntry {
2017-10-11 03:09:04 +02:00
public:
ComPrivateDataEntry();
ComPrivateDataEntry(
2017-10-11 03:09:04 +02:00
REFGUID guid,
UINT size,
const void* data);
ComPrivateDataEntry(
2017-10-11 03:09:04 +02:00
REFGUID guid,
const IUnknown* iface);
~ComPrivateDataEntry();
2017-10-11 03:09:04 +02:00
ComPrivateDataEntry (ComPrivateDataEntry&& other);
ComPrivateDataEntry& operator = (ComPrivateDataEntry&& other);
2017-10-11 03:09:04 +02:00
/**
* \brief The entry's GUID
* \returns The GUID
*/
REFGUID guid() const {
return m_guid;
}
/**
* \brief Checks whether the GUID matches another one
*
* GUIDs are used to identify private data entries.
* \param [in] guid The GUID to compare to
* \returns \c true if this entry holds the same GUID
*/
bool hasGuid(REFGUID guid) const {
return m_guid == guid;
}
/**
* \brief Retrieves stored data
*
* \param [in,out] size Destination buffer size
* \param [in] data Appliaction-provided buffer
* \returns \c S_OK on success, or \c DXGI_ERROR_MORE_DATA
* if the destination buffer is too small
*/
HRESULT get(UINT& size, void* data) const;
private:
GUID m_guid = __uuidof(IUnknown);
UINT m_size = 0;
void* m_data = nullptr;
IUnknown* m_iface = nullptr;
void destroy();
};
/**
* \brief Private storage for DXGI objects
*
* Provides storage for application-defined
* byte arrays or COM interfaces that can be
* retrieved using GUIDs.
*/
class ComPrivateData {
2017-10-11 03:09:04 +02:00
public:
HRESULT setData(
REFGUID guid,
UINT size,
const void* data);
HRESULT setInterface(
REFGUID guid,
const IUnknown* iface);
HRESULT getData(
REFGUID guid,
UINT* size,
void* data);
private:
std::vector<ComPrivateDataEntry> m_entries;
2017-10-11 03:09:04 +02:00
ComPrivateDataEntry* findEntry(REFGUID guid);
void insertEntry(ComPrivateDataEntry&& entry);
2017-10-11 03:09:04 +02:00
};
}