mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 14:52:11 +01:00
[d3d11] Implement ID3D11Device2
Adds some extra validation to resource creation so that apps cannot accidentally create tiled resources.
This commit is contained in:
parent
c1a7243811
commit
7ba7178d14
@ -204,6 +204,10 @@ namespace dxvk {
|
|||||||
if (!pDesc->ByteWidth)
|
if (!pDesc->ByteWidth)
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
// We don't support tiled resources
|
||||||
|
if (pDesc->MiscFlags & (D3D11_RESOURCE_MISC_TILE_POOL | D3D11_RESOURCE_MISC_TILED))
|
||||||
|
return E_INVALIDARG;
|
||||||
|
|
||||||
// Basic validation for structured buffers
|
// Basic validation for structured buffers
|
||||||
if ((pDesc->MiscFlags & D3D11_RESOURCE_MISC_BUFFER_STRUCTURED)
|
if ((pDesc->MiscFlags & D3D11_RESOURCE_MISC_BUFFER_STRUCTURED)
|
||||||
&& ((pDesc->StructureByteStride == 0)
|
&& ((pDesc->StructureByteStride == 0)
|
||||||
|
@ -1040,6 +1040,13 @@ namespace dxvk {
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HRESULT STDMETHODCALLTYPE D3D11Device::CreateDeferredContext2(
|
||||||
|
UINT ContextFlags,
|
||||||
|
ID3D11DeviceContext2** ppDeferredContext) {
|
||||||
|
*ppDeferredContext = ref(new D3D11DeferredContext(this, m_dxvkDevice, ContextFlags));
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE D3D11Device::CreateDeviceContextState(
|
HRESULT STDMETHODCALLTYPE D3D11Device::CreateDeviceContextState(
|
||||||
UINT Flags,
|
UINT Flags,
|
||||||
const D3D_FEATURE_LEVEL* pFeatureLevels,
|
const D3D_FEATURE_LEVEL* pFeatureLevels,
|
||||||
@ -1125,12 +1132,28 @@ namespace dxvk {
|
|||||||
DXGI_FORMAT Format,
|
DXGI_FORMAT Format,
|
||||||
UINT SampleCount,
|
UINT SampleCount,
|
||||||
UINT* pNumQualityLevels) {
|
UINT* pNumQualityLevels) {
|
||||||
|
return CheckMultisampleQualityLevels1(Format, SampleCount, 0, pNumQualityLevels);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HRESULT STDMETHODCALLTYPE D3D11Device::CheckMultisampleQualityLevels1(
|
||||||
|
DXGI_FORMAT Format,
|
||||||
|
UINT SampleCount,
|
||||||
|
UINT Flags,
|
||||||
|
UINT* pNumQualityLevels) {
|
||||||
// There are many error conditions, so we'll just assume
|
// There are many error conditions, so we'll just assume
|
||||||
// that we will fail and return a non-zero value in case
|
// that we will fail and return a non-zero value in case
|
||||||
// the device does actually support the format.
|
// the device does actually support the format.
|
||||||
if (!pNumQualityLevels)
|
if (!pNumQualityLevels)
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
// We don't support tiled resources, but it's unclear what
|
||||||
|
// we are supposed to return in this case. Be conservative.
|
||||||
|
if (Flags) {
|
||||||
|
*pNumQualityLevels = 0;
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
// For some reason, we can query DXGI_FORMAT_UNKNOWN
|
// For some reason, we can query DXGI_FORMAT_UNKNOWN
|
||||||
if (Format == DXGI_FORMAT_UNKNOWN) {
|
if (Format == DXGI_FORMAT_UNKNOWN) {
|
||||||
*pNumQualityLevels = SampleCount == 1 ? 1 : 0;
|
*pNumQualityLevels = SampleCount == 1 ? 1 : 0;
|
||||||
@ -1397,6 +1420,11 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void STDMETHODCALLTYPE D3D11Device::GetImmediateContext2(ID3D11DeviceContext2** ppImmediateContext) {
|
||||||
|
*ppImmediateContext = ref(m_context);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE D3D11Device::SetExceptionMode(UINT RaiseFlags) {
|
HRESULT STDMETHODCALLTYPE D3D11Device::SetExceptionMode(UINT RaiseFlags) {
|
||||||
Logger::err("D3D11Device::SetExceptionMode: Not implemented");
|
Logger::err("D3D11Device::SetExceptionMode: Not implemented");
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
@ -1409,6 +1437,21 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void STDMETHODCALLTYPE D3D11Device::GetResourceTiling(
|
||||||
|
ID3D11Resource* pTiledResource,
|
||||||
|
UINT* pNumTilesForEntireResource,
|
||||||
|
D3D11_PACKED_MIP_DESC* pPackedMipDesc,
|
||||||
|
D3D11_TILE_SHAPE* pStandardTileShapeForNonPackedMips,
|
||||||
|
UINT* pNumSubresourceTilings,
|
||||||
|
UINT FirstSubresourceTilingToGet,
|
||||||
|
D3D11_SUBRESOURCE_TILING* pSubresourceTilingsForNonPackedMips) {
|
||||||
|
static bool s_errorShown = false;
|
||||||
|
|
||||||
|
if (!std::exchange(s_errorShown, true))
|
||||||
|
Logger::err("D3D11Device::GetResourceTiling: Not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DXGI_VK_FORMAT_INFO D3D11Device::LookupFormat(
|
DXGI_VK_FORMAT_INFO D3D11Device::LookupFormat(
|
||||||
DXGI_FORMAT Format,
|
DXGI_FORMAT Format,
|
||||||
DXGI_VK_FORMAT_MODE Mode) const {
|
DXGI_VK_FORMAT_MODE Mode) const {
|
||||||
@ -1995,7 +2038,8 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (riid == __uuidof(ID3D11Device)
|
if (riid == __uuidof(ID3D11Device)
|
||||||
|| riid == __uuidof(ID3D11Device1)) {
|
|| riid == __uuidof(ID3D11Device1)
|
||||||
|
|| riid == __uuidof(ID3D11Device2)) {
|
||||||
*ppvObject = ref(&m_d3d11Device);
|
*ppvObject = ref(&m_d3d11Device);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ namespace dxvk {
|
|||||||
* Implements the ID3D11Device interfaces
|
* Implements the ID3D11Device interfaces
|
||||||
* as part of a \ref D3D11DeviceContainer.
|
* as part of a \ref D3D11DeviceContainer.
|
||||||
*/
|
*/
|
||||||
class D3D11Device final : public ID3D11Device1 {
|
class D3D11Device final : public ID3D11Device2 {
|
||||||
/// Maximum number of resource init commands per command buffer
|
/// Maximum number of resource init commands per command buffer
|
||||||
constexpr static uint64_t InitCommandThreshold = 50;
|
constexpr static uint64_t InitCommandThreshold = 50;
|
||||||
public:
|
public:
|
||||||
@ -206,6 +206,10 @@ namespace dxvk {
|
|||||||
UINT ContextFlags,
|
UINT ContextFlags,
|
||||||
ID3D11DeviceContext1** ppDeferredContext);
|
ID3D11DeviceContext1** ppDeferredContext);
|
||||||
|
|
||||||
|
HRESULT STDMETHODCALLTYPE CreateDeferredContext2(
|
||||||
|
UINT ContextFlags,
|
||||||
|
ID3D11DeviceContext2** ppDeferredContext);
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE CreateDeviceContextState(
|
HRESULT STDMETHODCALLTYPE CreateDeviceContextState(
|
||||||
UINT Flags,
|
UINT Flags,
|
||||||
const D3D_FEATURE_LEVEL* pFeatureLevels,
|
const D3D_FEATURE_LEVEL* pFeatureLevels,
|
||||||
@ -240,6 +244,12 @@ namespace dxvk {
|
|||||||
UINT SampleCount,
|
UINT SampleCount,
|
||||||
UINT* pNumQualityLevels);
|
UINT* pNumQualityLevels);
|
||||||
|
|
||||||
|
HRESULT STDMETHODCALLTYPE CheckMultisampleQualityLevels1(
|
||||||
|
DXGI_FORMAT Format,
|
||||||
|
UINT SampleCount,
|
||||||
|
UINT Flags,
|
||||||
|
UINT* pNumQualityLevels);
|
||||||
|
|
||||||
void STDMETHODCALLTYPE CheckCounterInfo(
|
void STDMETHODCALLTYPE CheckCounterInfo(
|
||||||
D3D11_COUNTER_INFO* pCounterInfo);
|
D3D11_COUNTER_INFO* pCounterInfo);
|
||||||
|
|
||||||
@ -285,10 +295,22 @@ namespace dxvk {
|
|||||||
void STDMETHODCALLTYPE GetImmediateContext1(
|
void STDMETHODCALLTYPE GetImmediateContext1(
|
||||||
ID3D11DeviceContext1** ppImmediateContext);
|
ID3D11DeviceContext1** ppImmediateContext);
|
||||||
|
|
||||||
|
void STDMETHODCALLTYPE GetImmediateContext2(
|
||||||
|
ID3D11DeviceContext2** ppImmediateContext);
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE SetExceptionMode(UINT RaiseFlags);
|
HRESULT STDMETHODCALLTYPE SetExceptionMode(UINT RaiseFlags);
|
||||||
|
|
||||||
UINT STDMETHODCALLTYPE GetExceptionMode();
|
UINT STDMETHODCALLTYPE GetExceptionMode();
|
||||||
|
|
||||||
|
void STDMETHODCALLTYPE GetResourceTiling(
|
||||||
|
ID3D11Resource* pTiledResource,
|
||||||
|
UINT* pNumTilesForEntireResource,
|
||||||
|
D3D11_PACKED_MIP_DESC* pPackedMipDesc,
|
||||||
|
D3D11_TILE_SHAPE* pStandardTileShapeForNonPackedMips,
|
||||||
|
UINT* pNumSubresourceTilings,
|
||||||
|
UINT FirstSubresourceTilingToGet,
|
||||||
|
D3D11_SUBRESOURCE_TILING* pSubresourceTilingsForNonPackedMips);
|
||||||
|
|
||||||
Rc<DxvkDevice> GetDXVKDevice() {
|
Rc<DxvkDevice> GetDXVKDevice() {
|
||||||
return m_dxvkDevice;
|
return m_dxvkDevice;
|
||||||
}
|
}
|
||||||
|
@ -282,6 +282,10 @@ namespace dxvk {
|
|||||||
!= (D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET))
|
!= (D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET))
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
// TILE_POOL is invalid, but we don't support TILED either
|
||||||
|
if (pDesc->MiscFlags & (D3D11_RESOURCE_MISC_TILE_POOL | D3D11_RESOURCE_MISC_TILED))
|
||||||
|
return E_INVALIDARG;
|
||||||
|
|
||||||
// Use the maximum possible mip level count if the supplied
|
// Use the maximum possible mip level count if the supplied
|
||||||
// mip level count is either unspecified (0) or invalid
|
// mip level count is either unspecified (0) or invalid
|
||||||
const uint32_t maxMipLevelCount = pDesc->SampleDesc.Count <= 1
|
const uint32_t maxMipLevelCount = pDesc->SampleDesc.Count <= 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user