From fefc3fcb3d96355436930fe9026e285608e0db90 Mon Sep 17 00:00:00 2001 From: GamebabyRockSun <41750362@qq.com> Date: Sat, 26 Oct 2019 11:47:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BA=86GRS=5FTHROW=5FIF=5FF?= =?UTF-8?q?AILED=E5=AE=8F=E5=AE=9A=E4=B9=89=EF=BC=8C=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E5=9B=A0=E5=AE=8F=E5=B1=95=E5=BC=80=E5=B8=A6=E6=9D=A5=E7=9A=84?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E8=B0=83=E7=94=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1-D3D12Triangle/1-D3D12Trigger.cpp | 2 +- 10-PixelShaderTips/10-PixelShaderTips.cpp | 12 +++++++----- 2-D3D12WICTexture/2-D3D12WICTexture.cpp | 2 +- 3-PlacedTexture/3-D3D12PlacedTexture.cpp | 2 +- 4-D3D12TextureCube/4-D3D12TextureCube.cpp | 3 ++- 5-SkyBox/5-SkyBox.cpp | 2 +- 6-MultiThread/6-MultiThread.cpp | 2 +- 6-MultiThread/6-MultiThreadWithMsgWait.cpp | 2 +- 7-D3D12MultiAdapter/7-D3D12MultiAdapter.cpp | 2 +- 8-UIRenderBase/8-UIRenderBase.cpp | 3 ++- 9-D3D12RenderToTexture/9-RenderToTexture.cpp | 2 +- 11 files changed, 19 insertions(+), 15 deletions(-) diff --git a/1-D3D12Triangle/1-D3D12Trigger.cpp b/1-D3D12Triangle/1-D3D12Trigger.cpp index 3cfbab0..e25e697 100644 --- a/1-D3D12Triangle/1-D3D12Trigger.cpp +++ b/1-D3D12Triangle/1-D3D12Trigger.cpp @@ -26,7 +26,7 @@ using namespace DirectX; #define GRS_WND_CLASS_NAME _T("GRS Game Window Class") #define GRS_WND_TITLE _T("GRS DirectX12 Trigger Sample") -#define GRS_THROW_IF_FAILED(hr) if (FAILED(hr)){ throw CGRSCOMException(hr); } +#define GRS_THROW_IF_FAILED(hr) {HRESULT _hr = (hr);if (FAILED(_hr)){ throw CGRSCOMException(_hr); }} class CGRSCOMException { diff --git a/10-PixelShaderTips/10-PixelShaderTips.cpp b/10-PixelShaderTips/10-PixelShaderTips.cpp index afe02bd..64ccc18 100644 --- a/10-PixelShaderTips/10-PixelShaderTips.cpp +++ b/10-PixelShaderTips/10-PixelShaderTips.cpp @@ -30,7 +30,7 @@ using namespace DirectX; #define GRS_WND_CLASS_NAME _T("GRS Game Window Class") #define GRS_WND_TITLE _T("GRS DirectX12 MultiThread Sample") -#define GRS_THROW_IF_FAILED(hr) if (FAILED(hr)){ throw CGRSCOMException(hr); } +#define GRS_THROW_IF_FAILED(hr) {HRESULT _hr = (hr);if (FAILED(_hr)){ throw CGRSCOMException(_hr); }} //新定义的宏用于上取整除法 #define GRS_UPPER_DIV(A,B) ((UINT)(((A)+((B)-1))/(B))) @@ -161,7 +161,7 @@ struct ST_GRS_THREAD_PARAMS XMFLOAT2 v2TexSize; TCHAR pszDDSFile[MAX_PATH]; CHAR pszMeshFile[MAX_PATH]; - ID3D12Device4* pID3DDevice; + ID3D12Device* pID3DDevice; ID3D12CommandAllocator* pICmdAlloc; ID3D12GraphicsCommandList* pICmdList; ID3D12RootSignature* pIRS; @@ -234,7 +234,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l ComPtr pIDXGIFactory5; ComPtr pIAdapter; - ComPtr pID3DDevice; + ComPtr pID3DDevice; ComPtr pIMainCmdQueue; ComPtr pISwapChain1; ComPtr pISwapChain3; @@ -343,6 +343,8 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l {//选择NUMA架构的独显来创建3D设备对象,暂时先不支持集显了,当然你可以修改这些行为 D3D12_FEATURE_DATA_ARCHITECTURE stArchitecture = {}; DXGI_ADAPTER_DESC1 stAdapterDesc = {}; + D3D_FEATURE_LEVEL emFeatureLevel = D3D_FEATURE_LEVEL_11_0; + HRESULT hr = S_OK; for (UINT nAdapterIndex = 0; DXGI_ERROR_NOT_FOUND != pIDXGIFactory5->EnumAdapters1(nAdapterIndex, &pIAdapter); ++nAdapterIndex) @@ -356,7 +358,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l } GRS_THROW_IF_FAILED(D3D12CreateDevice(pIAdapter.Get() - , D3D_FEATURE_LEVEL_12_1 + , emFeatureLevel , IID_PPV_ARGS(&pID3DDevice))); GRS_THROW_IF_FAILED(pID3DDevice->CheckFeatureSupport( @@ -704,7 +706,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR l { USES_CONVERSION; // 球体个性参数 - StringCchPrintf(g_stThreadParams[g_nThdSphere].pszDDSFile, MAX_PATH, _T("%s\\Mesh\\7777.dds"), g_pszAppPath); + StringCchPrintf(g_stThreadParams[g_nThdSphere].pszDDSFile, MAX_PATH, _T("%s\\Mesh\\Earth_512.dds"), g_pszAppPath); StringCchPrintfA(g_stThreadParams[g_nThdSphere].pszMeshFile, MAX_PATH, "%s\\Mesh\\sphere.txt", T2A(g_pszAppPath)); g_stThreadParams[g_nThdSphere].v4ModelPos = XMFLOAT4(2.0f, 2.0f, 0.0f, 1.0f); diff --git a/2-D3D12WICTexture/2-D3D12WICTexture.cpp b/2-D3D12WICTexture/2-D3D12WICTexture.cpp index e446b06..fc4d79b 100644 --- a/2-D3D12WICTexture/2-D3D12WICTexture.cpp +++ b/2-D3D12WICTexture/2-D3D12WICTexture.cpp @@ -26,7 +26,7 @@ using namespace DirectX; #define GRS_WND_CLASS_NAME _T("GRS Game Window Class") #define GRS_WND_TITLE _T("GRS DirectX12 Texture Sample") -#define GRS_THROW_IF_FAILED(hr) if (FAILED(hr)){ throw CGRSCOMException(hr); } +#define GRS_THROW_IF_FAILED(hr) {HRESULT _hr = (hr);if (FAILED(_hr)){ throw CGRSCOMException(_hr); }} class CGRSCOMException { diff --git a/3-PlacedTexture/3-D3D12PlacedTexture.cpp b/3-PlacedTexture/3-D3D12PlacedTexture.cpp index cbce3c3..09a7247 100644 --- a/3-PlacedTexture/3-D3D12PlacedTexture.cpp +++ b/3-PlacedTexture/3-D3D12PlacedTexture.cpp @@ -26,7 +26,7 @@ using namespace DirectX; #define GRS_WND_CLASS_NAME _T("GRS Game Window Class") #define GRS_WND_TITLE _T("GRS DirectX12 Texture Sample") -#define GRS_THROW_IF_FAILED(hr) if (FAILED(hr)){ throw CGRSCOMException(hr); } +#define GRS_THROW_IF_FAILED(hr) {HRESULT _hr = (hr);if (FAILED(_hr)){ throw CGRSCOMException(_hr); }} //新定义的宏用于上取整除法 #define GRS_UPPER_DIV(A,B) ((UINT)(((A)+((B)-1))/(B))) diff --git a/4-D3D12TextureCube/4-D3D12TextureCube.cpp b/4-D3D12TextureCube/4-D3D12TextureCube.cpp index 9fc4adf..9953964 100644 --- a/4-D3D12TextureCube/4-D3D12TextureCube.cpp +++ b/4-D3D12TextureCube/4-D3D12TextureCube.cpp @@ -27,7 +27,8 @@ using namespace DirectX; #define GRS_WND_CLASS_NAME _T("GRS Game Window Class") #define GRS_WND_TITLE _T("GRS DirectX12 Texture Sample") -#define GRS_THROW_IF_FAILED(hr) if (FAILED(hr)){ throw CGRSCOMException(hr); } +#define GRS_THROW_IF_FAILED(hr) {HRESULT _hr = (hr);if (FAILED(_hr)){ throw CGRSCOMException(_hr); }} + //新定义的宏用于上取整除法 #define GRS_UPPER_DIV(A,B) ((UINT)(((A)+((B)-1))/(B))) diff --git a/5-SkyBox/5-SkyBox.cpp b/5-SkyBox/5-SkyBox.cpp index 9abacc3..b58fba7 100644 --- a/5-SkyBox/5-SkyBox.cpp +++ b/5-SkyBox/5-SkyBox.cpp @@ -31,7 +31,7 @@ using namespace DirectX; #define GRS_WND_CLASS_NAME _T("GRS Game Window Class") #define GRS_WND_TITLE _T("GRS DirectX12 Texture Sample") -#define GRS_THROW_IF_FAILED(hr) if (FAILED(hr)){ throw CGRSCOMException(hr); } +#define GRS_THROW_IF_FAILED(hr) {HRESULT _hr = (hr);if (FAILED(_hr)){ throw CGRSCOMException(_hr); }} //新定义的宏用于上取整除法 #define GRS_UPPER_DIV(A,B) ((UINT)(((A)+((B)-1))/(B))) diff --git a/6-MultiThread/6-MultiThread.cpp b/6-MultiThread/6-MultiThread.cpp index 7cbfcbb..1c9143a 100644 --- a/6-MultiThread/6-MultiThread.cpp +++ b/6-MultiThread/6-MultiThread.cpp @@ -30,7 +30,7 @@ using namespace DirectX; #define GRS_WND_CLASS_NAME _T("GRS Game Window Class") #define GRS_WND_TITLE _T("GRS DirectX12 MultiThread Sample") -#define GRS_THROW_IF_FAILED(hr) if (FAILED(hr)){ throw CGRSCOMException(hr); } +#define GRS_THROW_IF_FAILED(hr) {HRESULT _hr = (hr);if (FAILED(_hr)){ throw CGRSCOMException(_hr); }} //新定义的宏用于上取整除法 #define GRS_UPPER_DIV(A,B) ((UINT)(((A)+((B)-1))/(B))) diff --git a/6-MultiThread/6-MultiThreadWithMsgWait.cpp b/6-MultiThread/6-MultiThreadWithMsgWait.cpp index 4d3405f..75fe510 100644 --- a/6-MultiThread/6-MultiThreadWithMsgWait.cpp +++ b/6-MultiThread/6-MultiThreadWithMsgWait.cpp @@ -30,7 +30,7 @@ using namespace DirectX; #define GRS_WND_CLASS_NAME _T("GRS Game Window Class") #define GRS_WND_TITLE _T("GRS DirectX12 MultiThread Sample") -#define GRS_THROW_IF_FAILED(hr) if (FAILED(hr)){ throw CGRSCOMException(hr); } +#define GRS_THROW_IF_FAILED(hr) {HRESULT _hr = (hr);if (FAILED(_hr)){ throw CGRSCOMException(_hr); }} //新定义的宏用于上取整除法 #define GRS_UPPER_DIV(A,B) ((UINT)(((A)+((B)-1))/(B))) diff --git a/7-D3D12MultiAdapter/7-D3D12MultiAdapter.cpp b/7-D3D12MultiAdapter/7-D3D12MultiAdapter.cpp index d8d652a..8edafd1 100644 --- a/7-D3D12MultiAdapter/7-D3D12MultiAdapter.cpp +++ b/7-D3D12MultiAdapter/7-D3D12MultiAdapter.cpp @@ -31,7 +31,7 @@ using namespace DirectX; #define GRS_WND_TITLE _T("GRS D3D12 MultiAdapter Sample") #define GRS_SAFE_RELEASE(p) if(p){(p)->Release();(p)=nullptr;} -#define GRS_THROW_IF_FAILED(hr) if (FAILED(hr)){ throw CGRSCOMException(hr); } +#define GRS_THROW_IF_FAILED(hr) {HRESULT _hr = (hr);if (FAILED(_hr)){ throw CGRSCOMException(_hr); }} //新定义的宏用于上取整除法 #define GRS_UPPER_DIV(A,B) ((UINT)(((A)+((B)-1))/(B))) diff --git a/8-UIRenderBase/8-UIRenderBase.cpp b/8-UIRenderBase/8-UIRenderBase.cpp index 0a87f68..7f80508 100644 --- a/8-UIRenderBase/8-UIRenderBase.cpp +++ b/8-UIRenderBase/8-UIRenderBase.cpp @@ -27,7 +27,8 @@ using namespace DirectX; #define GRS_WND_CLASS_NAME _T("GRS Game Window Class") #define GRS_WND_TITLE _T("GRS DirectX12 UI Render Base Sample") -#define GRS_THROW_IF_FAILED(hr) if (FAILED(hr)){ throw CGRSCOMException(hr); } +#define GRS_THROW_IF_FAILED(hr) {HRESULT _hr = (hr);if (FAILED(_hr)){ throw CGRSCOMException(_hr); }} + //更简洁的向上边界对齐算法 内存管理中常用 请记住 #define GRS_UPPER(A,B) ((UINT)(((A)+((B)-1))&~(B - 1))) diff --git a/9-D3D12RenderToTexture/9-RenderToTexture.cpp b/9-D3D12RenderToTexture/9-RenderToTexture.cpp index aece2b0..45dae87 100644 --- a/9-D3D12RenderToTexture/9-RenderToTexture.cpp +++ b/9-D3D12RenderToTexture/9-RenderToTexture.cpp @@ -28,7 +28,7 @@ using namespace DirectX; #define GRS_WND_CLASS_NAME _T("GRS Game Window Class") #define GRS_WND_TITLE _T("GRS DirectX12 Render To Texture Sample") -#define GRS_THROW_IF_FAILED(hr) if (FAILED(hr)){ throw CGRSCOMException(hr); } +#define GRS_THROW_IF_FAILED(hr) {HRESULT _hr = (hr);if (FAILED(_hr)){ throw CGRSCOMException(_hr); }} //新定义的宏用于上取整除法 #define GRS_UPPER_DIV(A,B) ((UINT)(((A)+((B)-1))/(B))) -- GitLab