我试图部分更新一个常量缓冲区(如在opengl中),但我总是得到奇怪的错误,我在这里错过了一些东西,因为我刚刚移植到DX11.1以获得Constant缓冲区部分更新功能(我也支持)它和CBOffsetting)
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]
答案 0 :(得分:1)
right
中D3D11_BOX
的值是位置,而不是宽度。您需要一起添加offset
和size
以获取right
的值。 sDstBox
应初始化为:
const D3D11_BOX sDstBox = { offset, 0U, 0U, offset + size, 1U, 1U };