提交 2b50a20d 编写于 作者: GamebabyRockSun_QQ's avatar GamebabyRockSun_QQ

去除了示例11多线程+多显卡渲染示例中所有d3dx12.h的引用

上级 0f023258
......@@ -74,10 +74,8 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
UINT64 n64FenceValue = 0ui64;
HANDLE hEventFence = nullptr;
D3D12_VIEWPORT stViewPort = { 0.0f, 0.0f
, static_cast<float>(iWidth), static_cast<float>(iHeight), D3D12_MIN_DEPTH, D3D12_MAX_DEPTH };
D3D12_RECT stScissorRect = { 0, 0
, static_cast<LONG>(iWidth), static_cast<LONG>(iHeight) };
D3D12_VIEWPORT stViewPort = { 0.0f, 0.0f, static_cast<float>(iWidth), static_cast<float>(iHeight), D3D12_MIN_DEPTH, D3D12_MAX_DEPTH };
D3D12_RECT stScissorRect = { 0, 0, static_cast<LONG>(iWidth), static_cast<LONG>(iHeight) };
D3D_FEATURE_LEVEL emFeatureLevel = D3D_FEATURE_LEVEL_12_1;
......
......@@ -148,12 +148,6 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\WindowsCommons\DDSTextureLoader12.cpp" />
<ClCompile Include="11-MultiThreadAndAdapter_NoMultiThread.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="11-MultiThreadAndAdapter.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
......
......@@ -21,9 +21,6 @@
<ClCompile Include="..\WindowsCommons\DDSTextureLoader12.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="11-MultiThreadAndAdapter_NoMultiThread.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="11-MultiThreadAndAdapter.cpp">
<Filter>源文件</Filter>
</ClCompile>
......
......@@ -1051,17 +1051,17 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
//偏移描述符指针到指定帧缓冲视图位置
CD3DX12_CPU_DESCRIPTOR_HANDLE stRTVHandle(g_pIRTVHeap->GetCPUDescriptorHandleForHeapStart()
, m_nCurrentFrameIndex, g_nRTVDescriptorSize);
CD3DX12_CPU_DESCRIPTOR_HANDLE dsvHandle(g_pIDSVHeap->GetCPUDescriptorHandleForHeapStart()
CD3DX12_CPU_DESCRIPTOR_HANDLE stDSVHandle(g_pIDSVHeap->GetCPUDescriptorHandleForHeapStart()
,1
, pID3D12Device4->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_DSV));
//设置渲染目标
pICmdListPre->OMSetRenderTargets(1, &stRTVHandle, FALSE, &dsvHandle);
pICmdListPre->OMSetRenderTargets(1, &stRTVHandle, FALSE, &stDSVHandle);
pICmdListPre->RSSetViewports(1, &g_stViewPort);
pICmdListPre->RSSetScissorRects(1, &g_stScissorRect);
pICmdListPre->ClearRenderTargetView(stRTVHandle, faClearColor, 0, nullptr);
pICmdListPre->ClearDepthStencilView(dsvHandle, D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, nullptr);
pICmdListPre->ClearDepthStencilView(stDSVHandle, D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, nullptr);
}
......@@ -1543,11 +1543,11 @@ UINT __stdcall RenderThread(void* pParam)
CD3DX12_CPU_DESCRIPTOR_HANDLE stRTVHandle(g_pIRTVHeap->GetCPUDescriptorHandleForHeapStart()
, pThdPms->m_nCurrentFrameIndex
, g_nRTVDescriptorSize);
CD3DX12_CPU_DESCRIPTOR_HANDLE dsvHandle(g_pIDSVHeap->GetCPUDescriptorHandleForHeapStart()
CD3DX12_CPU_DESCRIPTOR_HANDLE stDSVHandle(g_pIDSVHeap->GetCPUDescriptorHandleForHeapStart()
, 1
, pThdPms->m_pID3D12Device4->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_DSV));
//设置渲染目标
pThdPms->m_pICmdList->OMSetRenderTargets(1, &stRTVHandle, FALSE, &dsvHandle);
pThdPms->m_pICmdList->OMSetRenderTargets(1, &stRTVHandle, FALSE, &stDSVHandle);
pThdPms->m_pICmdList->RSSetViewports(1, &g_stViewPort);
pThdPms->m_pICmdList->RSSetScissorRects(1, &g_stScissorRect);
}
......
......@@ -201,10 +201,8 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
UINT nBPP = 0u;
DXGI_FORMAT stTextureFormat = DXGI_FORMAT_UNKNOWN;
D3D12_VIEWPORT stViewPort = { 0.0f, 0.0f
, static_cast<float>(iWidth), static_cast<float>(iHeight), D3D12_MIN_DEPTH, D3D12_MAX_DEPTH };
D3D12_RECT stScissorRect = { 0, 0
, static_cast<LONG>(iWidth), static_cast<LONG>(iHeight) };
D3D12_VIEWPORT stViewPort = { 0.0f, 0.0f, static_cast<float>(iWidth), static_cast<float>(iHeight), D3D12_MIN_DEPTH, D3D12_MAX_DEPTH };
D3D12_RECT stScissorRect = { 0, 0, static_cast<LONG>(iWidth), static_cast<LONG>(iHeight) };
ComPtr<IDXGIFactory5> pIDXGIFactory5;
ComPtr<IDXGIAdapter1> pIAdapter1;
......@@ -324,8 +322,6 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
// 创建DXGI Factory对象
{
GRS_THROW_IF_FAILED(CreateDXGIFactory2(nDXGIFactoryFlags, IID_PPV_ARGS(&pIDXGIFactory5)));
// 关闭ALT+ENTER键切换全屏的功能,因为我们没有实现OnSize处理,所以先关闭
GRS_THROW_IF_FAILED(pIDXGIFactory5->MakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER));
}
// 枚举适配器,并选择合适的适配器来创建3D设备对象
......@@ -410,6 +406,8 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
pID3D12Device4->CreateRenderTargetView(pIARenderTargets[i].Get(), nullptr, stRTVHandle);
stRTVHandle.ptr += nRTVDescriptorSize;
}
// 关闭ALT+ENTER键切换全屏的功能,因为我们没有实现OnSize处理,所以先关闭
GRS_THROW_IF_FAILED(pIDXGIFactory5->MakeWindowAssociation(hWnd, DXGI_MWA_NO_ALT_ENTER));
}
// 创建SRV堆 (Shader Resource View Heap)
......
......@@ -216,7 +216,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
UINT nSamplerDescriptorSize = 0; //采样器大小
D3D12_VIEWPORT stViewPort = { 0.0f, 0.0f, static_cast<float>(iWidth), static_cast<float>(iHeight) };
D3D12_VIEWPORT stViewPort = { 0.0f, 0.0f, static_cast<float>(iWidth), static_cast<float>(iHeight), D3D12_MIN_DEPTH, D3D12_MAX_DEPTH };
D3D12_RECT stScissorRect = { 0, 0, static_cast<LONG>(iWidth), static_cast<LONG>(iHeight) };
ComPtr<IDXGIFactory5> pIDXGIFactory5;
......
......@@ -234,7 +234,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
UINT nSamplerDescriptorSize = 0; //采样器大小
D3D12_VIEWPORT stViewPort = { 0.0f, 0.0f, static_cast<float>(iWidth), static_cast<float>(iHeight) };
D3D12_VIEWPORT stViewPort = { 0.0f, 0.0f, static_cast<float>(iWidth), static_cast<float>(iHeight), D3D12_MIN_DEPTH, D3D12_MAX_DEPTH };
D3D12_RECT stScissorRect = { 0, 0, static_cast<LONG>(iWidth), static_cast<LONG>(iHeight) };
ComPtr<IDXGIFactory5> pIDXGIFactory5;
......
......@@ -272,6 +272,8 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
UINT64 n64szUploadBufEarth = 0;
UINT64 n64szUploadBufSkybox = 0;
DXGI_FORMAT emRTFormat = DXGI_FORMAT_R8G8B8A8_UNORM;
DXGI_FORMAT emDSFormat = DXGI_FORMAT_D32_FLOAT;
DXGI_FORMAT emTxtFmtEarth = DXGI_FORMAT_UNKNOWN;
const float faClearColor[] = { 0.0f, 0.2f, 0.4f, 1.0f };
......@@ -285,7 +287,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
UINT nSamplerDescriptorSize = 0; //采样器大小
D3D12_VIEWPORT stViewPort = { 0.0f, 0.0f, static_cast<float>(iWndWidth), static_cast<float>(iWndHeight) };
D3D12_VIEWPORT stViewPort = { 0.0f, 0.0f, static_cast<float>(iWndWidth), static_cast<float>(iWndHeight), D3D12_MIN_DEPTH, D3D12_MAX_DEPTH };
D3D12_RECT stScissorRect = { 0, 0, static_cast<LONG>(iWndWidth), static_cast<LONG>(iWndHeight) };
//球体的网格数据
......@@ -604,7 +606,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
stSwapChainDesc.BufferCount = nFrameBackBufCount;
stSwapChainDesc.Width = iWndWidth;
stSwapChainDesc.Height = iWndHeight;
stSwapChainDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
stSwapChainDesc.Format = emRTFormat;
stSwapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
stSwapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
stSwapChainDesc.SampleDesc.Count = 1;
......@@ -654,12 +656,12 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
stDSBufHeapDesc.VisibleNodeMask = 0;
D3D12_DEPTH_STENCIL_VIEW_DESC stDepthStencilDesc = {};
stDepthStencilDesc.Format = DXGI_FORMAT_D32_FLOAT;
stDepthStencilDesc.Format = emDSFormat;
stDepthStencilDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D;
stDepthStencilDesc.Flags = D3D12_DSV_FLAG_NONE;
D3D12_CLEAR_VALUE depthOptimizedClearValue = {};
depthOptimizedClearValue.Format = DXGI_FORMAT_D32_FLOAT;
depthOptimizedClearValue.Format = emDSFormat;
depthOptimizedClearValue.DepthStencil.Depth = 1.0f;
depthOptimizedClearValue.DepthStencil.Stencil = 0;
......@@ -670,7 +672,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
stDSResDesc.Height = iWndHeight;
stDSResDesc.DepthOrArraySize = 1;
stDSResDesc.MipLevels = 0;
stDSResDesc.Format = DXGI_FORMAT_D32_FLOAT;
stDSResDesc.Format = emDSFormat;
stDSResDesc.SampleDesc.Count = 1;
stDSResDesc.SampleDesc.Quality = 0;
stDSResDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
......@@ -849,8 +851,8 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
stPSODesc.SampleMask = UINT_MAX;
stPSODesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
stPSODesc.NumRenderTargets = 1;
stPSODesc.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM;
stPSODesc.DSVFormat = DXGI_FORMAT_D32_FLOAT;
stPSODesc.RTVFormats[0] = emRTFormat;
stPSODesc.DSVFormat = emDSFormat;
stPSODesc.DepthStencilState.DepthEnable = TRUE;
stPSODesc.DepthStencilState.DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL;//启用深度缓存写入功能
stPSODesc.DepthStencilState.DepthFunc = D3D12_COMPARISON_FUNC_LESS; //深度测试函数(该值为普通的深度测试)
......@@ -1495,10 +1497,10 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
cbvDesc.BufferLocation = pICBUploadEarth->GetGPUVirtualAddress();
cbvDesc.SizeInBytes = static_cast<UINT>(szMVPBuf);
D3D12_CPU_DESCRIPTOR_HANDLE cbvSrvHandle = pISRVHpEarth->GetCPUDescriptorHandleForHeapStart();
cbvSrvHandle.ptr += nSRVDescriptorSize;
D3D12_CPU_DESCRIPTOR_HANDLE stSRVCBVHandle = pISRVHpEarth->GetCPUDescriptorHandleForHeapStart();
stSRVCBVHandle.ptr += nSRVDescriptorSize;
pID3D12Device4->CreateConstantBufferView(&cbvDesc, cbvSrvHandle);
pID3D12Device4->CreateConstantBufferView(&cbvDesc, stSRVCBVHandle);
//---------------------------------------------------------------------------------------------
cbvDesc.BufferLocation = pICBUploadSkybox->GetGPUVirtualAddress();
......@@ -1739,9 +1741,9 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
//偏移描述符指针到指定帧缓冲视图位置
D3D12_CPU_DESCRIPTOR_HANDLE stRTVHandle = pIRTVHeap->GetCPUDescriptorHandleForHeapStart();
stRTVHandle.ptr += (nCurrentFrameIndex * nRTVDescriptorSize);
D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = pIDSVHeap->GetCPUDescriptorHandleForHeapStart();
D3D12_CPU_DESCRIPTOR_HANDLE stDSVHandle = pIDSVHeap->GetCPUDescriptorHandleForHeapStart();
//设置渲染目标
pICmdListDirect->OMSetRenderTargets(1, &stRTVHandle, FALSE, &dsvHandle);
pICmdListDirect->OMSetRenderTargets(1, &stRTVHandle, FALSE, &stDSVHandle);
pICmdListDirect->RSSetViewports(1, &stViewPort);
pICmdListDirect->RSSetScissorRects(1, &stScissorRect);
......
......@@ -167,7 +167,7 @@ struct ST_GRS_THREAD_PARAMS
int g_iWndWidth = 1024;
int g_iWndHeight = 768;
D3D12_VIEWPORT g_stViewPort = { 0.0f, 0.0f, static_cast<float>(g_iWndWidth), static_cast<float>(g_iWndHeight) };
D3D12_VIEWPORT g_stViewPort = { 0.0f, 0.0f, static_cast<float>(g_iWndWidth), static_cast<float>(g_iWndHeight), D3D12_MIN_DEPTH, D3D12_MAX_DEPTH };
D3D12_RECT g_stScissorRect = { 0, 0, static_cast<LONG>(g_iWndWidth), static_cast<LONG>(g_iWndHeight) };
//初始的默认摄像机的位置
......@@ -837,15 +837,15 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
//偏移描述符指针到指定帧缓冲视图位置
D3D12_CPU_DESCRIPTOR_HANDLE stRTVHandle = g_pIRTVHeap->GetCPUDescriptorHandleForHeapStart();
stRTVHandle.ptr += ( nCurrentFrameIndex * g_nRTVDescriptorSize);
D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = g_pIDSVHeap->GetCPUDescriptorHandleForHeapStart();
D3D12_CPU_DESCRIPTOR_HANDLE stDSVHandle = g_pIDSVHeap->GetCPUDescriptorHandleForHeapStart();
//设置渲染目标
pICmdListPre->OMSetRenderTargets(1, &stRTVHandle, FALSE, &dsvHandle);
pICmdListPre->OMSetRenderTargets(1, &stRTVHandle, FALSE, &stDSVHandle);
pICmdListPre->RSSetViewports(1, &g_stViewPort);
pICmdListPre->RSSetScissorRects(1, &g_stScissorRect);
pICmdListPre->ClearRenderTargetView(stRTVHandle, faClearColor, 0, nullptr);
pICmdListPre->ClearDepthStencilView(dsvHandle, D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, nullptr);
pICmdListPre->ClearDepthStencilView(stDSVHandle, D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, nullptr);
}
nStates = 2;
......@@ -1390,9 +1390,9 @@ UINT __stdcall RenderThread(void* pParam)
{
D3D12_CPU_DESCRIPTOR_HANDLE stRTVHandle = g_pIRTVHeap->GetCPUDescriptorHandleForHeapStart();
stRTVHandle.ptr += ( pThdPms->nCurrentFrameIndex * g_nRTVDescriptorSize);
D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = g_pIDSVHeap->GetCPUDescriptorHandleForHeapStart();
D3D12_CPU_DESCRIPTOR_HANDLE stDSVHandle = g_pIDSVHeap->GetCPUDescriptorHandleForHeapStart();
//设置渲染目标
pThdPms->pICmdList->OMSetRenderTargets(1, &stRTVHandle, FALSE, &dsvHandle);
pThdPms->pICmdList->OMSetRenderTargets(1, &stRTVHandle, FALSE, &stDSVHandle);
pThdPms->pICmdList->RSSetViewports(1, &g_stViewPort);
pThdPms->pICmdList->RSSetScissorRects(1, &g_stScissorRect);
}
......
......@@ -42,7 +42,7 @@ using namespace DirectX;
#define GRS_ALLOC(sz) ::HeapAlloc(GetProcessHeap(),0,(sz))
#define GRS_CALLOC(sz) ::HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(sz))
#define GRS_CREALLOC(p,sz) ::HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,(p),(sz))
#define GRS_SAFE_FREE(p) if( nullptr != (p) ){ ::HeapFree( ::GetProcessHeap(),0,(p) ); (p) = nullptr; }
#define GRS_SAFE_FREE(p) if( nullptr != (p) ){ ::HeapFree( ::GetProcessHeap(),0,(p) ); (p) = nullptr; }
//------------------------------------------------------------------------------------------------------------
// 为了调试加入下面的内联函数和宏定义,为每个接口对象设置名称,方便查看调试输出
......@@ -223,7 +223,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
DXGI_FORMAT emRTFmt = DXGI_FORMAT_R8G8B8A8_UNORM;
DXGI_FORMAT emDSFmt = DXGI_FORMAT_D24_UNORM_S8_UINT;
D3D12_VIEWPORT stViewPort = { 0.0f, 0.0f, static_cast<float>(nWndWidth), static_cast<float>(nWndHeight) };
D3D12_VIEWPORT stViewPort = { 0.0f, 0.0f, static_cast<float>(nWndWidth), static_cast<float>(nWndHeight), D3D12_MIN_DEPTH, D3D12_MAX_DEPTH };
D3D12_RECT stScissorRect = { 0, 0, static_cast<LONG>(nWndWidth), static_cast<LONG>(nWndHeight) };
const UINT nMaxGPUParams = 2; //演示仅支持两个GPU进行渲染
......@@ -375,12 +375,6 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
// 枚举适配器创建设备
{// 使用DXGI的新函数EnumAdapterByGpuPreference来从高到低枚举系统中的显卡
//D3D12_FEATURE_DATA_ARCHITECTURE stArchitecture = {};
//ID3D12Device4* pID3DDeviceTmp = nullptr;
//IDXGIOutput* pIOutput = nullptr;
//HRESULT hrEnumOutput = S_OK;
DXGI_ADAPTER_DESC1 stAdapterDesc[nMaxGPUParams] = {};
IDXGIAdapter1* pIAdapterTmp = nullptr;
UINT i = 0;
......@@ -1133,11 +1127,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
stGPUParams[nIDGPUMain].m_pID3D12Device4->GetCopyableFootprints(&stDefaultResDesc, nFirstSubresource, nNumSubresources, 0, pLayouts, pNumRows, pRowSizesInBytes, &n64RequiredSize);
BYTE* pData = nullptr;
HRESULT hr = stModuleParams[i].pITextureUpload->Map(0, nullptr, reinterpret_cast<void**>(&pData));
if (FAILED(hr))
{
return 0;
}
GRS_THROW_IF_FAILED(stModuleParams[i].pITextureUpload->Map(0, nullptr, reinterpret_cast<void**>(&pData)));
// 第一遍Copy!注意3重循环每重的意思
for (UINT nSubRes = 0; nSubRes < nNumSubresources; ++nSubRes)
......@@ -1194,7 +1184,6 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
//同步
D3D12_RESOURCE_BARRIER stUploadTransResBarrier = {};
stUploadTransResBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
stUploadTransResBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
stUploadTransResBarrier.Transition.pResource = stModuleParams[i].pITexture.Get();
......@@ -1657,14 +1646,14 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = stGPUParams[nIDGPUMain].m_pIDHRTV->GetCPUDescriptorHandleForHeapStart();
rtvHandle.ptr += (nCurrentFrameIndex * stGPUParams[nIDGPUMain].m_nszRTV);
D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = stGPUParams[nIDGPUMain].m_pIDHDSVTex->GetCPUDescriptorHandleForHeapStart();
D3D12_CPU_DESCRIPTOR_HANDLE stDSVHandle = stGPUParams[nIDGPUMain].m_pIDHDSVTex->GetCPUDescriptorHandleForHeapStart();
stGPUParams[nIDGPUMain].m_pICmdList->OMSetRenderTargets(
1, &rtvHandle, false, &dsvHandle);
1, &rtvHandle, false, &stDSVHandle);
stGPUParams[nIDGPUMain].m_pICmdList->ClearRenderTargetView(
rtvHandle, arf4ClearColor, 0, nullptr);
stGPUParams[nIDGPUMain].m_pICmdList->ClearDepthStencilView(
dsvHandle, D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, nullptr);
stDSVHandle, D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, nullptr);
//执行实际的物体绘制渲染,Draw Call!
for (int i = 0; i < nMaxObject; i++)
......
......@@ -202,6 +202,8 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
UINT nFrame = 0;
UINT nRTVDescriptorSize = 0U;
UINT nSRVDescriptorSize = 0U;
UINT nSampleDescriptorSize = 0U;
HWND hWnd = nullptr;
MSG msg = {};
......@@ -224,7 +226,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
D3D12_PLACED_SUBRESOURCE_FOOTPRINT stTxtLayouts = {};
D3D12_RESOURCE_DESC stTextureDesc = {};
D3D12_VIEWPORT stViewPort = { 0.0f, 0.0f, static_cast<float>(iWndWidth), static_cast<float>(iWndHeight), 0.0f, 1.0f };
D3D12_VIEWPORT stViewPort = { 0.0f, 0.0f, static_cast<float>(iWndWidth), static_cast<float>(iWndHeight), D3D12_MIN_DEPTH, D3D12_MAX_DEPTH };
D3D12_RECT stScissorRect = { 0, 0, static_cast<LONG>(iWndWidth), static_cast<LONG>(iWndHeight) };
ComPtr<IDXGIFactory5> pIDXGIFactory5;
......@@ -491,6 +493,11 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
, stAdapterDesc.Description);
::SetWindowText(hWnd, pszWndTitle);
//得到每个描述符元素的大小
nRTVDescriptorSize = pID3D12Device4->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
nSRVDescriptorSize = pID3D12Device4->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
nSampleDescriptorSize = pID3D12Device4->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
}
// 创建直接命令队列
......@@ -552,8 +559,8 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
stRTVHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
GRS_THROW_IF_FAILED(pID3D12Device4->CreateDescriptorHeap(&stRTVHeapDesc, IID_PPV_ARGS(&pIRTVHeap)));
//得到每个描述符元素的大小
nRTVDescriptorSize = pID3D12Device4->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
//---------------------------------------------------------------------------------------------
//9、创建RTV的描述符
......@@ -1035,10 +1042,10 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
cbvDesc.BufferLocation = pICBMVO->GetGPUVirtualAddress();
cbvDesc.SizeInBytes = static_cast<UINT>(szCBBuf);
D3D12_CPU_DESCRIPTOR_HANDLE cbvSrvHandle = pISRVHeap->GetCPUDescriptorHandleForHeapStart();
cbvSrvHandle.ptr += pID3D12Device4->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
D3D12_CPU_DESCRIPTOR_HANDLE stSRVCBVHandle = pISRVHeap->GetCPUDescriptorHandleForHeapStart();
stSRVCBVHandle.ptr += nSRVDescriptorSize;
pID3D12Device4->CreateConstantBufferView(&cbvDesc, cbvSrvHandle);
pID3D12Device4->CreateConstantBufferView(&cbvDesc, stSRVCBVHandle);
// Sample View
D3D12_SAMPLER_DESC stSamplerDesc = {};
......@@ -1065,7 +1072,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
pICmdBundlesQuad->SetGraphicsRootDescriptorTable(0, pISRVHeap->GetGPUDescriptorHandleForHeapStart());
D3D12_GPU_DESCRIPTOR_HANDLE stGPUCBVHandle = pISRVHeap->GetGPUDescriptorHandleForHeapStart();
stGPUCBVHandle.ptr += pID3D12Device4->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
stGPUCBVHandle.ptr += nSRVDescriptorSize;
pICmdBundlesQuad->SetGraphicsRootDescriptorTable(1, stGPUCBVHandle);
pICmdBundlesQuad->SetGraphicsRootDescriptorTable(2, pISampleHeap->GetGPUDescriptorHandleForHeapStart());
......
......@@ -44,3 +44,15 @@ D3D12 ERROR: ID3D12CommandQueue::Present: Resource state (0x800: D3D12_RESOURCE_
2021-6-5
1、去除了示例7多显卡渲染中的d3dx12.h的所有引用;
2、去除了示例8 UI渲染中的d3dx12.h的所有引用;
2021-6-6
1、去除了示例9渲染到纹理示例中所有d3dx12.h的引用;
2、去除了示例10几个后处理特效示例中所有d3dx12.h的引用;
2021-6-7
1、去除了示例11多线程+多显卡渲染示例中所有d3dx12.h的引用;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册