gpt4 book ai didi

c++ - 如何在 DirectX 11.1 中部分更新常量缓冲区

转载 作者:行者123 更新时间:2023-11-28 04:56:32 34 4
gpt4 key购买 nike

我正在尝试部分更新常量缓冲区(如在 opengl 中),但我总是遇到奇怪的错误,我刚刚移植到 DX11.1 以获得常量缓冲区部分更新功能(我也支持它和 CBOoffsetting)

void DX11UniformBuffer::Update(void * data, unsigned int offset, unsigned int size)
{
const D3D11_BOX sDstBox = { offset, 0U, 0U, size, 1U, 1U };
DX11Context::GetContext()->UpdateSubresource1(buffer, 0, &sDstBox, data, 0, 0,D3D11_COPY_DISCARD);
DX11Context::GetContext()->PSSetConstantBuffers1(0, 1, &buffer, &offset, &size);
}

相当于(在 opengl 中)

void GLUniformBuffer::Update(void * data, unsigned int offset, unsigned int size)
{
glBindBuffer(GL_UNIFORM_BUFFER, buffer);
glBufferSubData(GL_UNIFORM_BUFFER, offset, size, data);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
}

但是我收到这些错误并且没有绘制任何内容...

D3D11 ERROR: ID3D11DeviceContext::UpdateSubresource1: pDstBox is not a valid box, as the End coordinates must be greater than or equal to the Start. *pDstBox = { left:144, top:0, front:0, right:48, bottom:1, back:1 }. [ RESOURCE_MANIPULATION ERROR #288: UPDATESUBRESOURCE_INVALIDDESTINATIONBOX]

最佳答案

D3D11_BOXright 的值是position,而不是width。您需要将 offsetsize 相加以获得 right 的值。 sDstBox 应初始化为:

const D3D11_BOX sDstBox = { offset, 0U, 0U, offset + size, 1U, 1U };

关于c++ - 如何在 DirectX 11.1 中部分更新常量缓冲区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47007141/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com