D3D12 ClearRenderTargetView

问题描述 投票:0回答:1

传递一个浮点数组并收到警告,“清除值与传递给资源创建的清除值不匹配。”

1没有警告的作品

2没有,我尝试使用GetFloatArray()方法,但仍然收到警告

渲染目标格式为:

clearValue.Format = DXGI_FORMAT::DXGI_FORMAT_R8G8B8A8_UNORM;

我的CColor对象:

float RGBA[4];

float* GetFloatArray()
{
    return RGBA;
}

ClearRenderTargetView(s):

// #1
globalObjects->videoDevice->commandList->ClearRenderTargetView(
   globalObjects->videoDevice->swapChainRenderTargets[globalObjects->videoDevice->frameIndex]->handle,
   CColorCornflowerBlue.GetFloatArray(), 0, nullptr);

// #2
const float c[4] =
{ 
    CColorLovelyPurple.RGBA[0],
    CColorLovelyPurple.RGBA[1],
    CColorLovelyPurple.RGBA[2],
    CColorLovelyPurple.RGBA[3]
};

commandList->ClearRenderTargetView(renderTargets[globalObjects->videoDevice->frameIndex]->handle,
c, 0, nullptr);

任何想法或如果其他想法有相同的问题,将不胜感激。

directx-12
1个回答
0
投票

您没有向我们展示创建渲染目标视图(renderTargets[globalObjects->videoDevice->frameIndex]->handle)的代码,但是当您创建它时,可以在D3D12_CLEAR_VALUE中设置清除值:

D3D12_CLEAR_VALUE clearValue = {};
clearValue.Format = DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;
clearValue.Color = c;

只需更改.Color以使其与呼叫commandList->ClearRenderTargetView()的颜色相匹配

© www.soinside.com 2019 - 2024. All rights reserved.