ID3D10Device::RSSetState 每帧都被调用?

发布于 2024-12-14 07:09:53 字数 1062 浏览 2 评论 0原文

我正在尝试使用 direct3D10 创建 ID3D10RasterizerState,然后

ID3D10Device::RSSetState()

使用正确的信息进行调用。但是,每当窗口重新缩放时,或者当应用程序进入全屏时,光栅化器状态似乎会重置为默认状态。 我尝试使用 WM_SIZE 消息设置状态,但尴尬的是,似乎没有发生任何事情......

当我每帧调用 RSSetState() 时它都能正常工作,但这似乎效率很低。

有谁知道这个问题的解决方案吗? msdn 上似乎没有很好的记录。

代码:

bool TestGameApp::InitGame()
{
    D3D10_RASTERIZER_DESC desc;
    desc.AntialiasedLineEnable = TRUE;
    desc.CullMode = D3D10_CULL_NONE;
    desc.DepthBias = 0;
    desc.DepthBiasClamp = 0.0f;
    desc.FillMode = D3D10_FILL_SOLID;
    desc.FrontCounterClockwise = false;
    desc.MultisampleEnable = true;
    desc.ScissorEnable = FALSE;
    desc.SlopeScaledDepthBias = 0.0f;

    m_pD3DDevice->CreateRasterizerState(&desc,m_pRSState);
    m_pD3DDevice->RSSetState(m_pRSState);

    //...more code
}

WndProc:

switch( message )
{
    case WM_SIZE:
    {
        m_pD3DDevice->RSSetState(m_pRSState);
        break;
    }
}

I am trying to create a ID3D10RasterizerState with direct3D10, and then call

ID3D10Device::RSSetState()

with the proper information. However, whenever the window get rescaled, or when the app goes fullscreen, the rasterizerstate seems to reset to the default state.
I have tried to set the state with WM_SIZE messages, but awkwardly, nothing seems to happen...

It works properly when I call RSSetState() every frame, but that seems highly inefficient.

Does anyone know a solution to this?
It seems to be poorly documented on msdn.

Code:

bool TestGameApp::InitGame()
{
    D3D10_RASTERIZER_DESC desc;
    desc.AntialiasedLineEnable = TRUE;
    desc.CullMode = D3D10_CULL_NONE;
    desc.DepthBias = 0;
    desc.DepthBiasClamp = 0.0f;
    desc.FillMode = D3D10_FILL_SOLID;
    desc.FrontCounterClockwise = false;
    desc.MultisampleEnable = true;
    desc.ScissorEnable = FALSE;
    desc.SlopeScaledDepthBias = 0.0f;

    m_pD3DDevice->CreateRasterizerState(&desc,m_pRSState);
    m_pD3DDevice->RSSetState(m_pRSState);

    //...more code
}

WndProc:

switch( message )
{
    case WM_SIZE:
    {
        m_pD3DDevice->RSSetState(m_pRSState);
        break;
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

╭ゆ眷念 2024-12-21 07:09:53

每一帧都设置一下就可以了。一般来说,您希望最大程度地减少帧中渲染状态更改的数量,但无需担心每帧设置一次光栅化器状态对性能的影响。每帧设置它还可以让您执行诸如启用和禁用线框渲染以进行调试之类的操作。

Just set it every frame. In general you want to minimize the number of render state changes in a frame but you don't need to worry about the performance impact of setting the rasterizer state once a frame. Setting it every frame also lets you do things like enable and disable wireframe rendering for debugging.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文