XNA Creators Club Online
Page 1 of 1 (5 items)
Sort Posts: Previous Next

Buffers and UpdateSubresource

Last post 5/25/2007 11:11 PM by Klavius. 4 replies.
  • 5/25/2007 1:22 PM

    Buffers and UpdateSubresource

    Hi,

    Just looking for a bit of a clarification on UpdatateSubresource()'s box parameter. I'm updating a subregion of a vertex buffer, and the box's left and right make perfect sense, for a 1D buffer, but bottom and back seem to make little difference, so long as they're nonzero. I just set them to 1 and it's all gravy (but anything positive seems to work too).

    Thanks!

     

    "My God, it's full of stars." -- Dave Bowman
  • 5/25/2007 2:04 PM In reply to

    Re: Buffers and UpdateSubresource

    Answer
    Reply Quote

    The box parameter for UpdateSubresource is a common source of confusion.

    Depending on the dimension of the resource some values seems not relevant at all. But there is a problem. If you set both elements of a pair (left – right; top – bottom; front – back) to the same value the box is defined as empty. An empty box would not trigger a copy operation. Therefore you need to set some value to bottom and back.

    I don’t know the exact details of the implementation but it looks like that the runtime does this empty box check before even checking how many dimensions the resource has. After you have pass this the additional parameters seems to be ignored.

  • 5/25/2007 2:32 PM In reply to

    Re: Buffers and UpdateSubresource

    Right, the empty box check makes sense.

    It just seems a bit odd to be able to pass any positive number at all, only to pass some internal test. I expect a crash when I pass bogus values, and feel cheated otherwise ;-)

    Thanks.

    "My God, it's full of stars." -- Dave Bowman
  • 5/25/2007 7:29 PM In reply to

    Re: Buffers and UpdateSubresource

    Answer
    Reply Quote

    For any dimensions that are not representative of the Resource type, you set the low coord to 0 and high coord to 1.

    For Buffers, you should set top & front to 0, and bottom & back to 1. I'm pretty sure the Debug Layer will complain about any random positive values. Out-of-bound coordinates are undefined (which includes crash or 'happens to work as intended').

  • 5/25/2007 11:11 PM In reply to

    Re: Buffers and UpdateSubresource

    Yes, the debug layer does indeed complain about an invalid box.

    Thanks!

    "My God, it's full of stars." -- Dave Bowman
Page 1 of 1 (5 items) Previous Next