Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
GamebabyRockSun_QQ
GRSD3D12Sample
提交
2b50a20d
G
GRSD3D12Sample
项目概览
GamebabyRockSun_QQ
/
GRSD3D12Sample
大约 1 年 前同步成功
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
G
GRSD3D12Sample
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2b50a20d
编写于
6月 07, 2021
作者:
GamebabyRockSun_QQ
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
去除了示例11多线程+多显卡渲染示例中所有d3dx12.h的引用
上级
0f023258
变更
16
展开全部
隐藏空白更改
内联
并排
Showing
16 changed file
with
1863 addition
and
3485 deletion
+1863
-3485
1-D3D12Triangle/1-D3D12Trigger.cpp
1-D3D12Triangle/1-D3D12Trigger.cpp
+2
-4
10-PixelShaderTips/10-PixelShaderTips.cpp
10-PixelShaderTips/10-PixelShaderTips.cpp
+410
-203
11-MultiThreadAndAdapter/11-MultiThreadAndAdapter.cpp
11-MultiThreadAndAdapter/11-MultiThreadAndAdapter.cpp
+979
-652
11-MultiThreadAndAdapter/11-MultiThreadAndAdapter.vcxproj
11-MultiThreadAndAdapter/11-MultiThreadAndAdapter.vcxproj
+0
-6
11-MultiThreadAndAdapter/11-MultiThreadAndAdapter.vcxproj.filters
...ThreadAndAdapter/11-MultiThreadAndAdapter.vcxproj.filters
+0
-3
11-MultiThreadAndAdapter/11-MultiThreadAndAdapter_NoMultiThread.cpp
...readAndAdapter/11-MultiThreadAndAdapter_NoMultiThread.cpp
+0
-2339
14-MultiThreadShadow/14-MultiThreadShadow-noshadow.cpp
14-MultiThreadShadow/14-MultiThreadShadow-noshadow.cpp
+5
-5
2-D3D12WICTexture/2-D3D12WICTexture.cpp
2-D3D12WICTexture/2-D3D12WICTexture.cpp
+4
-6
3-PlacedTexture/3-D3D12PlacedTexture.cpp
3-PlacedTexture/3-D3D12PlacedTexture.cpp
+1
-1
4-D3D12TextureCube/4-D3D12TextureCube.cpp
4-D3D12TextureCube/4-D3D12TextureCube.cpp
+1
-1
5-SkyBox/5-SkyBox.cpp
5-SkyBox/5-SkyBox.cpp
+14
-12
6-MultiThread/6-MultiThreadWithMsgWait.cpp
6-MultiThread/6-MultiThreadWithMsgWait.cpp
+6
-6
7-D3D12MultiAdapter/7-D3D12MultiAdapter.cpp
7-D3D12MultiAdapter/7-D3D12MultiAdapter.cpp
+6
-17
8-UIRenderBase/8-UIRenderBase.cpp
8-UIRenderBase/8-UIRenderBase.cpp
+14
-7
9-D3D12RenderToTexture/9-RenderToTexture.cpp
9-D3D12RenderToTexture/9-RenderToTexture.cpp
+409
-223
Revision.md
Revision.md
+12
-0
未找到文件。
1-D3D12Triangle/1-D3D12Trigger.cpp
浏览文件 @
2b50a20d
...
...
@@ -74,10 +74,8 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
UINT64
n64FenceValue
=
0u
i64
;
HANDLE
hEventFence
=
nullptr
;
D3D12_VIEWPORT
stViewPort
=
{
0.0
f
,
0.0
f
,
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.0
f
,
0.0
f
,
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
;
...
...
10-PixelShaderTips/10-PixelShaderTips.cpp
浏览文件 @
2b50a20d
此差异已折叠。
点击以展开。
11-MultiThreadAndAdapter/11-MultiThreadAndAdapter.cpp
浏览文件 @
2b50a20d
此差异已折叠。
点击以展开。
11-MultiThreadAndAdapter/11-MultiThreadAndAdapter.vcxproj
浏览文件 @
2b50a20d
...
...
@@ -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>
...
...
11-MultiThreadAndAdapter/11-MultiThreadAndAdapter.vcxproj.filters
浏览文件 @
2b50a20d
...
...
@@ -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>
...
...
11-MultiThreadAndAdapter/11-MultiThreadAndAdapter_NoMultiThread.cpp
已删除
100644 → 0
浏览文件 @
0f023258
此差异已折叠。
点击以展开。
14-MultiThreadShadow/14-MultiThreadShadow-noshadow.cpp
浏览文件 @
2b50a20d
...
...
@@ -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
dsv
Handle
(
g_pIDSVHeap
->
GetCPUDescriptorHandleForHeapStart
()
CD3DX12_CPU_DESCRIPTOR_HANDLE
stDSV
Handle
(
g_pIDSVHeap
->
GetCPUDescriptorHandleForHeapStart
()
,
1
,
pID3D12Device4
->
GetDescriptorHandleIncrementSize
(
D3D12_DESCRIPTOR_HEAP_TYPE_DSV
));
//设置渲染目标
pICmdListPre
->
OMSetRenderTargets
(
1
,
&
stRTVHandle
,
FALSE
,
&
dsv
Handle
);
pICmdListPre
->
OMSetRenderTargets
(
1
,
&
stRTVHandle
,
FALSE
,
&
stDSV
Handle
);
pICmdListPre
->
RSSetViewports
(
1
,
&
g_stViewPort
);
pICmdListPre
->
RSSetScissorRects
(
1
,
&
g_stScissorRect
);
pICmdListPre
->
ClearRenderTargetView
(
stRTVHandle
,
faClearColor
,
0
,
nullptr
);
pICmdListPre
->
ClearDepthStencilView
(
dsv
Handle
,
D3D12_CLEAR_FLAG_DEPTH
,
1.0
f
,
0
,
0
,
nullptr
);
pICmdListPre
->
ClearDepthStencilView
(
stDSV
Handle
,
D3D12_CLEAR_FLAG_DEPTH
,
1.0
f
,
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
dsv
Handle
(
g_pIDSVHeap
->
GetCPUDescriptorHandleForHeapStart
()
CD3DX12_CPU_DESCRIPTOR_HANDLE
stDSV
Handle
(
g_pIDSVHeap
->
GetCPUDescriptorHandleForHeapStart
()
,
1
,
pThdPms
->
m_pID3D12Device4
->
GetDescriptorHandleIncrementSize
(
D3D12_DESCRIPTOR_HEAP_TYPE_DSV
));
//设置渲染目标
pThdPms
->
m_pICmdList
->
OMSetRenderTargets
(
1
,
&
stRTVHandle
,
FALSE
,
&
dsv
Handle
);
pThdPms
->
m_pICmdList
->
OMSetRenderTargets
(
1
,
&
stRTVHandle
,
FALSE
,
&
stDSV
Handle
);
pThdPms
->
m_pICmdList
->
RSSetViewports
(
1
,
&
g_stViewPort
);
pThdPms
->
m_pICmdList
->
RSSetScissorRects
(
1
,
&
g_stScissorRect
);
}
...
...
2-D3D12WICTexture/2-D3D12WICTexture.cpp
浏览文件 @
2b50a20d
...
...
@@ -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.0
f
,
0.0
f
,
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.0
f
,
0.0
f
,
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)
...
...
3-PlacedTexture/3-D3D12PlacedTexture.cpp
浏览文件 @
2b50a20d
...
...
@@ -216,7 +216,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
UINT
nSamplerDescriptorSize
=
0
;
//采样器大小
D3D12_VIEWPORT
stViewPort
=
{
0.0
f
,
0.0
f
,
static_cast
<
float
>
(
iWidth
),
static_cast
<
float
>
(
iHeight
)
};
D3D12_VIEWPORT
stViewPort
=
{
0.0
f
,
0.0
f
,
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
;
...
...
4-D3D12TextureCube/4-D3D12TextureCube.cpp
浏览文件 @
2b50a20d
...
...
@@ -234,7 +234,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
UINT
nSamplerDescriptorSize
=
0
;
//采样器大小
D3D12_VIEWPORT
stViewPort
=
{
0.0
f
,
0.0
f
,
static_cast
<
float
>
(
iWidth
),
static_cast
<
float
>
(
iHeight
)
};
D3D12_VIEWPORT
stViewPort
=
{
0.0
f
,
0.0
f
,
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
;
...
...
5-SkyBox/5-SkyBox.cpp
浏览文件 @
2b50a20d
...
...
@@ -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.0
f
,
0.2
f
,
0.4
f
,
1.0
f
};
...
...
@@ -285,7 +287,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l
UINT
nSamplerDescriptorSize
=
0
;
//采样器大小
D3D12_VIEWPORT
stViewPort
=
{
0.0
f
,
0.0
f
,
static_cast
<
float
>
(
iWndWidth
),
static_cast
<
float
>
(
iWndHeight
)
};
D3D12_VIEWPORT
stViewPort
=
{
0.0
f
,
0.0
f
,
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.0
f
;
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
cbvSrv
Handle
=
pISRVHpEarth
->
GetCPUDescriptorHandleForHeapStart
();
cbvSrv
Handle
.
ptr
+=
nSRVDescriptorSize
;
D3D12_CPU_DESCRIPTOR_HANDLE
stSRVCBV
Handle
=
pISRVHpEarth
->
GetCPUDescriptorHandleForHeapStart
();
stSRVCBV
Handle
.
ptr
+=
nSRVDescriptorSize
;
pID3D12Device4
->
CreateConstantBufferView
(
&
cbvDesc
,
cbvSrv
Handle
);
pID3D12Device4
->
CreateConstantBufferView
(
&
cbvDesc
,
stSRVCBV
Handle
);
//---------------------------------------------------------------------------------------------
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
dsv
Handle
=
pIDSVHeap
->
GetCPUDescriptorHandleForHeapStart
();
D3D12_CPU_DESCRIPTOR_HANDLE
stDSV
Handle
=
pIDSVHeap
->
GetCPUDescriptorHandleForHeapStart
();
//设置渲染目标
pICmdListDirect
->
OMSetRenderTargets
(
1
,
&
stRTVHandle
,
FALSE
,
&
dsv
Handle
);
pICmdListDirect
->
OMSetRenderTargets
(
1
,
&
stRTVHandle
,
FALSE
,
&
stDSV
Handle
);
pICmdListDirect
->
RSSetViewports
(
1
,
&
stViewPort
);
pICmdListDirect
->
RSSetScissorRects
(
1
,
&
stScissorRect
);
...
...
6-MultiThread/6-MultiThreadWithMsgWait.cpp
浏览文件 @
2b50a20d
...
...
@@ -167,7 +167,7 @@ struct ST_GRS_THREAD_PARAMS
int
g_iWndWidth
=
1024
;
int
g_iWndHeight
=
768
;
D3D12_VIEWPORT
g_stViewPort
=
{
0.0
f
,
0.0
f
,
static_cast
<
float
>
(
g_iWndWidth
),
static_cast
<
float
>
(
g_iWndHeight
)
};
D3D12_VIEWPORT
g_stViewPort
=
{
0.0
f
,
0.0
f
,
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
dsv
Handle
=
g_pIDSVHeap
->
GetCPUDescriptorHandleForHeapStart
();
D3D12_CPU_DESCRIPTOR_HANDLE
stDSV
Handle
=
g_pIDSVHeap
->
GetCPUDescriptorHandleForHeapStart
();
//设置渲染目标
pICmdListPre
->
OMSetRenderTargets
(
1
,
&
stRTVHandle
,
FALSE
,
&
dsv
Handle
);
pICmdListPre
->
OMSetRenderTargets
(
1
,
&
stRTVHandle
,
FALSE
,
&
stDSV
Handle
);
pICmdListPre
->
RSSetViewports
(
1
,
&
g_stViewPort
);
pICmdListPre
->
RSSetScissorRects
(
1
,
&
g_stScissorRect
);
pICmdListPre
->
ClearRenderTargetView
(
stRTVHandle
,
faClearColor
,
0
,
nullptr
);
pICmdListPre
->
ClearDepthStencilView
(
dsv
Handle
,
D3D12_CLEAR_FLAG_DEPTH
,
1.0
f
,
0
,
0
,
nullptr
);
pICmdListPre
->
ClearDepthStencilView
(
stDSV
Handle
,
D3D12_CLEAR_FLAG_DEPTH
,
1.0
f
,
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
dsv
Handle
=
g_pIDSVHeap
->
GetCPUDescriptorHandleForHeapStart
();
D3D12_CPU_DESCRIPTOR_HANDLE
stDSV
Handle
=
g_pIDSVHeap
->
GetCPUDescriptorHandleForHeapStart
();
//设置渲染目标
pThdPms
->
pICmdList
->
OMSetRenderTargets
(
1
,
&
stRTVHandle
,
FALSE
,
&
dsv
Handle
);
pThdPms
->
pICmdList
->
OMSetRenderTargets
(
1
,
&
stRTVHandle
,
FALSE
,
&
stDSV
Handle
);
pThdPms
->
pICmdList
->
RSSetViewports
(
1
,
&
g_stViewPort
);
pThdPms
->
pICmdList
->
RSSetScissorRects
(
1
,
&
g_stScissorRect
);
}
...
...
7-D3D12MultiAdapter/7-D3D12MultiAdapter.cpp
浏览文件 @
2b50a20d
...
...
@@ -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.0
f
,
0.0
f
,
static_cast
<
float
>
(
nWndWidth
),
static_cast
<
float
>
(
nWndHeight
)
};
D3D12_VIEWPORT
stViewPort
=
{
0.0
f
,
0.0
f
,
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
dsv
Handle
=
stGPUParams
[
nIDGPUMain
].
m_pIDHDSVTex
->
GetCPUDescriptorHandleForHeapStart
();
D3D12_CPU_DESCRIPTOR_HANDLE
stDSV
Handle
=
stGPUParams
[
nIDGPUMain
].
m_pIDHDSVTex
->
GetCPUDescriptorHandleForHeapStart
();
stGPUParams
[
nIDGPUMain
].
m_pICmdList
->
OMSetRenderTargets
(
1
,
&
rtvHandle
,
false
,
&
dsv
Handle
);
1
,
&
rtvHandle
,
false
,
&
stDSV
Handle
);
stGPUParams
[
nIDGPUMain
].
m_pICmdList
->
ClearRenderTargetView
(
rtvHandle
,
arf4ClearColor
,
0
,
nullptr
);
stGPUParams
[
nIDGPUMain
].
m_pICmdList
->
ClearDepthStencilView
(
dsv
Handle
,
D3D12_CLEAR_FLAG_DEPTH
,
1.0
f
,
0
,
0
,
nullptr
);
stDSV
Handle
,
D3D12_CLEAR_FLAG_DEPTH
,
1.0
f
,
0
,
0
,
nullptr
);
//执行实际的物体绘制渲染,Draw Call!
for
(
int
i
=
0
;
i
<
nMaxObject
;
i
++
)
...
...
8-UIRenderBase/8-UIRenderBase.cpp
浏览文件 @
2b50a20d
...
...
@@ -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.0
f
,
0.0
f
,
static_cast
<
float
>
(
iWndWidth
),
static_cast
<
float
>
(
iWndHeight
),
0.0
f
,
1.0
f
};
D3D12_VIEWPORT
stViewPort
=
{
0.0
f
,
0.0
f
,
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
cbvSrv
Handle
=
pISRVHeap
->
GetCPUDescriptorHandleForHeapStart
();
cbvSrvHandle
.
ptr
+=
pID3D12Device4
->
GetDescriptorHandleIncrementSize
(
D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV
)
;
D3D12_CPU_DESCRIPTOR_HANDLE
stSRVCBV
Handle
=
pISRVHeap
->
GetCPUDescriptorHandleForHeapStart
();
stSRVCBVHandle
.
ptr
+=
nSRVDescriptorSize
;
pID3D12Device4
->
CreateConstantBufferView
(
&
cbvDesc
,
cbvSrv
Handle
);
pID3D12Device4
->
CreateConstantBufferView
(
&
cbvDesc
,
stSRVCBV
Handle
);
// 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
());
...
...
9-D3D12RenderToTexture/9-RenderToTexture.cpp
浏览文件 @
2b50a20d
此差异已折叠。
点击以展开。
Revision.md
浏览文件 @
2b50a20d
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录