PFND3D10DDI_RESOURCEMAP回呼函式 (d3d10umddi.h)
ResourceMap 函式會對應資源的子資源。
語法
PFND3D10DDI_RESOURCEMAP Pfnd3d10ddiResourcemap;
void Pfnd3d10ddiResourcemap(
D3D10DDI_HDEVICE unnamedParam1,
D3D10DDI_HRESOURCE unnamedParam2,
UINT unnamedParam3,
D3D10_DDI_MAP unnamedParam4,
UINT unnamedParam5,
D3D10DDI_MAPPED_SUBRESOURCE *unnamedParam6
)
{...}
參數
unnamedParam1
hDevice [in]
顯示裝置的句柄 (圖形內容) 。
unnamedParam2
hResource [in]
要對應的資源句柄。
unnamedParam3
子資源 [in]
索引,表示要對應的子資源。
unnamedParam4
DDIMap [in]
D3D10_DDI_MAP型別值,表示要對應子資源的存取層級。
unnamedParam5
旗標 [in]
指出如何對應子資源的 D3D10_DDI_MAP_FLAG型別值。
unnamedParam6
pMappedSubResource [out]
接收對應子資源相關信息 之D3D10DDI_MAPPED_SUBRESOURCE 結構的指標。
傳回值
無
備註
驅動程式可以使用 pfnSetErrorCb 回呼函式來設定錯誤碼。
驅動程式可以呼叫 pfnSetErrorCb 來設定D3DDDIERR_DEVICEREMOVED錯誤碼。
一般而言,在運行時間收到D3DDDIERR_DEVICEREMOVED錯誤碼之後,運行時間將不再呼叫使用者模式顯示 (驅動程式,而不需要取消系結、解構和其他清除作業) 。
一般而言,使用者模式顯示驅動程式 ResourceMap 函式的每個呼叫都會伴隨對驅動程式 ResourceUnmap 函式的呼叫;不過,在運行時間收到D3DDDIERR_DEVICEREMOVED錯誤碼之後,它不會呼叫 ResourceUnmap。
如果運行時間在 Flags 參數中傳遞D3D10_DDI_MAP_FLAG_DONOTWAIT旗標,驅動程式可以呼叫 pfnSetErrorCb 來設定DXGI_DDI_ERR_WASSTILLDRAWING錯誤碼。
驅動程式可以實作一對 ResourceMap 和 ResourceUnmap 函式,其中包含 switch 語句來處理各種功能。 也就是說,驅動程式可以實作一個 ResourceMap-ResourceUnmap 配對,並可設定 下列D3D10DDI_DEVICEFUNCS 結構成員,以指向此實作配對:
pfnDynamicIABufferMapDiscard-pfnDynamicIABufferUnmap
pfnDynamicIABufferMapNoOverwrite-pfnDynamicIABufferUnmap
pfnDynamicConstantBufferMapDiscard-pfnDynamicConstantBufferUnmap
pfnDynamicResourceMapDiscard-pfnDynamicResourceUnmap
pfnStagingResourceMap-pfnStagingResourceUnmap
不過,為了改善效能,驅動程式可以實作個別的對應 unmap 函式組。 Microsoft Direct3D 運行時間會根據資源類型 (呼叫適當的對應 unmap 函式配對,例如緩衝區或紋理) 以及建立和對應資源時所指定的 D3D10_DDI_RESOURCE_USAGE、 D3D10_DDI_RESOURCE_BIND_FLAG和 D3D10_DDI_MAP 值。
注意
如果要對應和取消對應的資源類型是緩衝區,Direct3D 運行時間會將 Subresource 參數設定為零。
雖然 Direct3D 執行時間通常會針對動態紋理呼叫 pfnDynamicResourceMapDiscard-pfnDynamicResourceUnmap 函式組,但運行時間也會針對使用已設定D3D10_DDI_BIND_SHADER_RESOURCE系結旗標所建立的動態緩衝區呼叫此函式組。
下列範例程式代碼顯示 Direct3D 執行時間呼叫特定對應或 unmap 函式時所設定的值:
//-----------------------------------------------
void APIENTRY UMDevice::DynamicIABufferMapNoOverwrite_Default(
D3D10DDI_HDEVICE hDevice,
D3D10DDI_HRESOURCE hResource,
UINT Subresource,
D3D10_DDI_MAP MapType,
UINT MapFlags,
D3D10DDI_MAPPED_SUBRESOURCE* pMappedSubresource )
{
UMDevice* pThis = UMDevice::CastFrom( hDevice );
UMResource* pResource = UMResource::CastFrom( hResource );
assert( pResource->m_DDICreateResource.ResourceDimension == D3D10DDIRESOURCE_BUFFER &&
pResource->m_DDICreateResource.Usage == D3D10_DDI_USAGE_DYNAMIC &&
(pResource->m_DDICreateResource.BindFlags & (D3D10_DDI_BIND_VERTEX_BUFFER | D3D10_DDI_BIND_INDEX_BUFFER)) &&
!(pResource->m_DDICreateResource.BindFlags & ~(D3D10_DDI_BIND_VERTEX_BUFFER | D3D10_DDI_BIND_INDEX_BUFFER)) &&
Subresource == 0 &&
MapType == D3D10_DDI_MAP_WRITE_NOOVERWRITE &&
MapFlags == 0 );
pResource->Map( Subresource, MapType, MapFlags, pMappedSubresource );
}
//------------------------------------------------
void APIENTRY UMDevice::DynamicIABufferMapDiscard_Default(
D3D10DDI_HDEVICE hDevice,
D3D10DDI_HRESOURCE hResource,
UINT Subresource,
D3D10_DDI_MAP MapType,
UINT MapFlags,
D3D10DDI_MAPPED_SUBRESOURCE* pMappedSubresource )
{
UMDevice* pThis = UMDevice::CastFrom( hDevice );
UMResource* pResource = UMResource::CastFrom( hResource );
assert( pResource->m_DDICreateResource.ResourceDimension == D3D10DDIRESOURCE_BUFFER &&
pResource->m_DDICreateResource.Usage == D3D10_DDI_USAGE_DYNAMIC &&
(pResource->m_DDICreateResource.BindFlags & (D3D10_DDI_BIND_VERTEX_BUFFER | D3D10_DDI_BIND_INDEX_BUFFER)) &&
!(pResource->m_DDICreateResource.BindFlags & ~(D3D10_DDI_BIND_VERTEX_BUFFER | D3D10_DDI_BIND_INDEX_BUFFER)) &&
Subresource == 0 &&
MapType == D3D10_DDI_MAP_WRITE_DISCARD &&
MapFlags == 0 );
pResource->Map( Subresource, MapType, MapFlags, pMappedSubresource );
}
//------------------------------------------------
void APIENTRY UMDevice::DynamicIABufferUnmap_Default(
D3D10DDI_HDEVICE hDevice,
D3D10DDI_HRESOURCE hResource,
UINT Subresource )
{
UMDevice* pThis = UMDevice::CastFrom( hDevice );
UMResource* pResource = UMResource::CastFrom( hResource );
assert( pResource->m_DDICreateResource.ResourceDimension == D3D10DDIRESOURCE_BUFFER &&
pResource->m_DDICreateResource.Usage == D3D10_DDI_USAGE_DYNAMIC &&
(pResource->m_DDICreateResource.BindFlags & (D3D10_DDI_BIND_VERTEX_BUFFER | D3D10_DDI_BIND_INDEX_BUFFER)) &&
!(pResource->m_DDICreateResource.BindFlags & ~(D3D10_DDI_BIND_VERTEX_BUFFER | D3D10_DDI_BIND_INDEX_BUFFER)) &&
Subresource == 0 );
pResource->Unmap( Subresource );
}
//------------------------------------------------
void APIENTRY UMDevice::DynamicConstantBufferMapDiscard_Default(
D3D10DDI_HDEVICE hDevice,
D3D10DDI_HRESOURCE hResource,
UINT Subresource,
D3D10_DDI_MAP MapType,
UINT MapFlags,
D3D10DDI_MAPPED_SUBRESOURCE* pMappedSubresource )
{
UMDevice* pThis = UMDevice::CastFrom( hDevice );
UMResource* pResource = UMResource::CastFrom( hResource );
assert( pResource->m_DDICreateResource.ResourceDimension == D3D10DDIRESOURCE_BUFFER &&
pResource->m_DDICreateResource.Usage == D3D10_DDI_USAGE_DYNAMIC &&
(pResource->m_DDICreateResource.BindFlags & D3D10_DDI_BIND_CONSTANT_BUFFER) &&
!(pResource->m_DDICreateResource.BindFlags & ~D3D10_DDI_BIND_CONSTANT_BUFFER) &&
Subresource == 0 &&
MapType == D3D10_DDI_MAP_WRITE_DISCARD &&
MapFlags == 0 );
pResource->Map( Subresource, MapType, MapFlags, pMappedSubresource );
}
//------------------------------------------------
void APIENTRY UMDevice::DynamicConstantBufferUnmap_Default(
D3D10DDI_HDEVICE hDevice,
D3D10DDI_HRESOURCE hResource,
UINT Subresource )
{
UMDevice* pThis = UMDevice::CastFrom( hDevice );
UMResource* pResource = UMResource::CastFrom( hResource );
assert( pResource->m_DDICreateResource.ResourceDimension == D3D10DDIRESOURCE_BUFFER &&
pResource->m_DDICreateResource.Usage == D3D10_DDI_USAGE_DYNAMIC &&
(pResource->m_DDICreateResource.BindFlags & D3D10_DDI_BIND_CONSTANT_BUFFER) &&
!(pResource->m_DDICreateResource.BindFlags & ~D3D10_DDI_BIND_CONSTANT_BUFFER) &&
Subresource == 0 );
pResource->Unmap( Subresource );
}
//------------------------------------------------
void APIENTRY UMDevice::DynamicResourceMapDiscard_Default(
D3D10DDI_HDEVICE hDevice,
D3D10DDI_HRESOURCE hResource,
UINT Subresource,
D3D10_DDI_MAP MapType,
UINT MapFlags,
D3D10DDI_MAPPED_SUBRESOURCE* pMappedSubresource )
{
UMDevice* pThis = UMDevice::CastFrom( hDevice );
UMResource* pResource = UMResource::CastFrom( hResource );
assert( pResource->m_DDICreateResource.Usage == D3D10_DDI_USAGE_DYNAMIC &&
pResource->m_DDICreateResource.Subresources == 1 &&
Subresource == 0 &&
MapType == D3D10_DDI_MAP_WRITE_DISCARD &&
MapFlags == 0 );
pResource->Map( Subresource, MapType, MapFlags, pMappedSubresource );
}
//------------------------------------------------
void APIENTRY UMDevice::DynamicResourceUnmap_Default(
D3D10DDI_HDEVICE hDevice,
D3D10DDI_HRESOURCE hResource,
UINT Subresource )
{
UMDevice* pThis = UMDevice::CastFrom( hDevice );
UMResource* pResource = UMResource::CastFrom( hResource );
assert( pResource->m_DDICreateResource.Usage == D3D10_DDI_USAGE_DYNAMIC &&
pResource->m_DDICreateResource.Subresources == 1 &&
Subresource == 0 );
pResource->Unmap( Subresource );
}
//------------------------------------------------
void APIENTRY UMDevice::StagingResourceMap_Default(
D3D10DDI_HDEVICE hDevice,
D3D10DDI_HRESOURCE hResource,
UINT Subresource,
D3D10_DDI_MAP MapType,
UINT MapFlags,
D3D10DDI_MAPPED_SUBRESOURCE* pMappedSubresource )
{
UMDevice* pThis = UMDevice::CastFrom( hDevice );
UMResource* pResource = UMResource::CastFrom( hResource );
assert( pResource->m_DDICreateResource.Usage == D3D10_DDI_USAGE_STAGING &&
(MapType == D3D10_DDI_MAP_READ || MapType == D3D10_DDI_MAP_WRITE || MapType == D3D10_DDI_MAP_READWRITE) );
pResource->Map( Subresource, MapType, MapFlags, pMappedSubresource );
}
//------------------------------------------------
void APIENTRY UMDevice::StagingResourceUnmap_Default(
D3D10DDI_HDEVICE hDevice,
D3D10DDI_HRESOURCE hResource,
UINT Subresource )
{
UMDevice* pThis = UMDevice::CastFrom( hDevice );
UMResource* pResource = UMResource::CastFrom( hResource );
assert( pResource->m_DDICreateResource.Usage == D3D10_DDI_USAGE_STAGING );
pResource->Unmap( Subresource );
}
//------------------------------------------------
void APIENTRY UMDevice::ResourceMap_Default(
D3D10DDI_HDEVICE hDevice,
D3D10DDI_HRESOURCE hResource,
UINT Subresource,
D3D10_DDI_MAP MapType,
UINT MapFlags,
D3D10DDI_MAPPED_SUBRESOURCE* pMappedSubresource )
{
UMDevice* pThis = UMDevice::CastFrom( hDevice );
UMResource* pResource = UMResource::CastFrom( hResource );
assert( pResource->m_DDICreateResource.Usage != D3D10_DDI_USAGE_DYNAMIC &&
pResource->m_DDICreateResource.Usage != D3D10_DDI_USAGE_STAGING );
// Generally true; but allow last second change:
assert( false );
pResource->Map( Subresource, MapType, MapFlags, pMappedSubresource );
}
//------------------------------------------------
void APIENTRY UMDevice::ResourceUnmap_Default(
D3D10DDI_HDEVICE hDevice,
D3D10DDI_HRESOURCE hResource,
UINT Subresource )
{
UMDevice* pThis = UMDevice::CastFrom( hDevice );
UMResource* pResource = UMResource::CastFrom( hResource );
assert( pResource->m_DDICreateResource.Usage != D3D10_DDI
_USAGE_DYNAMIC &&
pResource->m_DDICreateResource.Usage != D3D10_DDI_USAGE_STAGING );
// Generally true; but allow last second change:
assert( false );
pResource->Unmap( Subresource );
}
輸入值的限制
對於 Windows 顯示驅動程式模型 (WDDM) 1.3 和更新版本的驅動程式,Microsoft Direct3D 運行時間會提供一組受限制的輸入值,供此函式使用。 如需所有受限制值的清單,請參閱 Direct3D 轉譯效能改善。
規格需求
需求 | 值 |
---|---|
最低支援的用戶端 | 可在 Windows Vista 和更新版本的 Windows 作業系統中使用。 |
目標平台 | 桌面 |
標頭 | d3d10umddi.h (包含 D3d10umddi.h) |