未處理的異常@ClearRenderTargetView() (Unhandled exception @ ClearRenderTargetView())


問題描述

未處理的異常@ClearRenderTargetView() (Unhandled exception @ ClearRenderTargetView())

So, I am using Visual Studio 2012 with the "onboard" Windows SDK 8, writing Direct3D11 applications and i have a huge problem. I have a class which handles all the initialization, setup and draw calls on top off D3D11. I instantiate the application class which holds an instance of the D3D11 driver class properly with all the data it needs to know.

The D3D11 driver class constructor takes the application's primary window handle and uses it to hook D3D into the application's primary window. It constructs itself properly and returns out where it calls app‑>run() which drives the main loop.

In the main loop, that driver is called to simply test draw a blank reddish screen. Observing the debug information, the render target in question is operational, created to bind the backbuffer from the swap chain to the pipeline.

renderTargetView IS NOT NULL. HRESULT is validated to be S_OK.

If I try to call the Draw function within the D3D11 driver class constructor, it works. It doesn't get deallocated inbetween calls. 

It's like the constructor of the Application class doesn't finish before the run() function, if I try to continue without exiting for a few "frames" forward, the reddish tint of the cleared render target shows. Can someone enlighten me, please? I'm at the end of my wits.

IT'S NOT NULL. HRESULT is validated to be S_OK. There are reports this is fixed in Windows 8, while the Win7 SDK still suffers. Google doesn't yield anything useful, most people forget to create the render target view (stays NULL) or intellisense‑miss OMSetRenderTargets for OMGetRenderTargets.

‑‑‑‑‑

參考解法

方法 1:

Unhandled exceptions are almost exclusively dropped when you dereference a null pointer. The ClearRenderTargetView() is an instance method of a validly initialized (immediate) context, or 

ID3D11DeviceContext::ClearRenderTargetView(...)

If you didn't make the trivial mistakes of not initializing the render target view or calling OMGetRenderTargets(...) instead of OMSetRenderTargets(...), I am absolutely certain that your context is null. Per your statement, you explicitly deny making these mistakes.

Use assert to verify my claim, that your context is indeed NULL. Since it works in your driver constructor and doesn't later when it is used as a member of your application class, you're probably not supplying a proper copy assignment operator in your driver class, that's why it drops an unhandled exception box, it initializes the context and then doesn't persist due to a missed reference copy. While the object is being initialized, it is partially valid, that's why it works that one time. 

This is just a hypothesis, I'm pretty certain, but due to the lack of code on your part, I can only use my imagination and logic. Report back if you need further assistance.

(by Fractal Resurgenceuser1309389)

參考文件

  1. Unhandled exception @ ClearRenderTargetView() (CC BY‑SA 3.0/4.0)

#direct3d11 #directx-11 #visual-c++ #directx






相關問題

Адлюстраванне дынамічнага буфера ў Direct3D11 у праграме Windows Store (Mapping a dynamic buffer in Direct3D11 in a Windows Store App)

未處理的異常@ClearRenderTargetView() (Unhandled exception @ ClearRenderTargetView())

將 3d 模型導入 Direct3D 11 示例 (Importing 3d model to Direct3D 11 Example)

編譯器不允許我使用“DDSTextureLoader.h”和“WICTextureLoader.h” (Compiler won't let me use "DDSTextureLoader.h" and "WICTextureLoader.h")

在我從舊版 DirectX SDK 更改為 Windows SDK (Visual Studio 2015) 後,鏈接器一直在抱怨 (The linker keeps complaining after I changed from legacy DirectX SDK to Windows SDK (Visual Studio 2015)))

鏈接器給出了我在我的應用程序中根本沒有使用過的函數的錯誤 (Linker gives errors about a function that i have not used in my application at all)

Direct3D 11 中輸出圖像的雙線性過濾 (Bilinear filtering of output image in Direct3D 11)

Direct3D 編程新手:11 與 12 (New to Direct3D programming: 11 vs 12)

如何在 Direct3D 11 上使用字體文件渲染文本? (How can I render text using font files on Direct3D 11?)

獲取 D3D 調試信息? (Get D3D debug information?)

為什麼 XMMatrixLookAtLH 會導致調試錯誤? (Why does XMMatrixLookAtLH result in a debug error?)

InterlockedAdd HLSL 潛在優化 (InterlockedAdd HLSL potential optimization)







留言討論