0

源代码:https ://github.com/AinoMegumi/Direct3D12

我正在尝试初始化 Direct3D12 窗口。

在函数 Direct3D12::OnFrameRender 中(观看上面的源代码,Direct3D12.cpp 第 251 行),

    void Direct3D12::OnFrameRender() {
    this->CommandList->RSSetViewports(0, &this->ViewPort); 
    SetResourceBarrier(D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET);
    float ClearColor[4] = { static_cast<float>(0xff) / 255.0f, static_cast<float>(0xc0) / 255.0f, static_cast<float>(0xcb) / 255.0f, 1.0f };
    this->CommandList->ClearRenderTargetView(this->CPUDescriptorHandle, ClearColor, 0, nullptr); // ここで落ちてる
    SetResourceBarrier(D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT);
    this->Present(0);
}

现在,我尝试调用 ClearRenderTargetView。但是,从 KernelBase.dll 引发了未处理的异常。

我调查 KernelBase.dll 并检测谁抛出异常。

观看此 asm 转储 https://pastebin.com/YBJLMBxE

场景是

  1. 在地址 00007FF8E6380977 上调用
  2. 在地址 00007FF8E6368AF2 系统调用上
  3. 跳转到地址 00007FF8E6380977!!!!
  4. 跳转到地址 00007FF8E6368AE0
  5. 在地址 00007FF8E6368AF2 系统调用上,

错误信息是

ハンドルされない例外が 0x00007FF8E27F3C58 (KernelBase.dll) で発生しました(Direct3D.exe 内): 0x0000087D (パラメーター: 0x0000000000000000, 0x00000028379BCE20, 0x0000021B7FD80FB0)。</p>

使用 ClearRenderTargetView 和初始化窗口的正确方法是什么?

4

1 回答 1

0

正确的RenderTargetView通话场景如下

  1. 每次CD3DX12_CPU_DESCRIPTOR_HANDLE变量
  2. 把它传给OMSetRenderTargets
  3. 称呼ClearRenderTargetView

https://github.com/AinoMegumi/Direct3D12/blob/eed1650b59aba61648e45758dc759a415dfb6b17/Direct3D/Direct3D12.cpp#L263-L266

于 2017-10-17T13:12:46.800 回答