2017-10-11 03:09:04 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2017-10-11 09:41:19 +02:00
|
|
|
#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.
|
|
|
|
*/
|
2017-10-11 09:41:19 +02:00
|
|
|
class ComPrivateDataEntry {
|
2017-10-11 03:09:04 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2017-10-11 09:41:19 +02:00
|
|
|
ComPrivateDataEntry();
|
|
|
|
ComPrivateDataEntry(
|
2017-10-11 03:09:04 +02:00
|
|
|
REFGUID guid,
|
|
|
|
UINT size,
|
|
|
|
const void* data);
|
2017-10-11 09:41:19 +02:00
|
|
|
ComPrivateDataEntry(
|
2017-10-11 03:09:04 +02:00
|
|
|
REFGUID guid,
|
|
|
|
const IUnknown* iface);
|
2017-10-11 09:41:19 +02:00
|
|
|
~ComPrivateDataEntry();
|
2017-10-11 03:09:04 +02:00
|
|
|
|
2017-10-11 09:41:19 +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.
|
|
|
|
*/
|
2017-10-11 09:41:19 +02:00
|
|
|
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:
|
|
|
|
|
2017-10-11 09:41:19 +02:00
|
|
|
std::vector<ComPrivateDataEntry> m_entries;
|
2017-10-11 03:09:04 +02:00
|
|
|
|
2017-10-11 09:41:19 +02:00
|
|
|
ComPrivateDataEntry* findEntry(REFGUID guid);
|
|
|
|
void insertEntry(ComPrivateDataEntry&& entry);
|
2017-10-11 03:09:04 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|