VSSetConstantBuffers1 does not appear to be working

by Mike   Last Updated May 28, 2018 06:13 AM

I'm experiencing something very strange here when using VSSetConstantBuffers1.

I have a projection * world matrix that I'm sending to a constant buffer to rotate a triangle on an axis. When I do this, I follow this pattern:

Frame #1

  • Set offset to 0, count is always at 64 (4 * float4)
  • Map Constant Buffer using Discard.
  • Write matrix to constant buffer
  • Unmap
  • Call VSSetConstantBuffers1(0, 1, new []{ cbuffer }, new []{offset }, new []{ count })
  • Draw

Frame #2

  • Set offset to 64, count remains same.
  • Map constant buffer using NoOverwrite
  • Write matrix.
  • Unmap
  • Call VSSetConstantBuffers1(0, 1, new []{ cbuffer }, new []{offset }, new []{ count })
  • Draw

Etc... When I fill the constant buffer completely, I reset offset to 0, and start again by using discard on my map.

Now here's my problem: Nothing shows up on the screen. Well, that's not 100% true, the very first frame, where offset = 0 and count = 64, that shows up perfectly. The next frame, and subsequent frames do not.

I used the Visual Studio 2017 graphics debugger to confirm that my constant buffer did indeed have data in it. And it did, and the values were correct.

It's really weird. I should be mapping the constant buffer to the next matrix element with my 2nd call to VSSetConstantBuffers1, but it doesn't actually look like it's going anywhere near that element.

Also, I tried forcing it to just use the 0, and 64 offset/count and only updating that portion of the buffer, and it works just fine.

I've tried my best to dig up info about constant buffer offset/count, but it's pretty sparse out there (my own searches on this site gave me 0 for VSSetConstantBuffers1, same with GameDev.net). What little I did scrounge up on Nvidia's website, makes it appear as though this pattern should work.

Since my hardware might come into question here, I have a GeForce 1080 GTX running on Windows 10 (latest update), and according to the D3D11.1 options, it does indeed support constant buffer offsets, and my feature level is at max.

Anyone have any ideas? Given the lack of info, I'm guessing the offset/count versions of constant buffers aren't too popular?



Related Questions




DDS files with DirectX Tk, Some work, some don't

Updated August 01, 2015 14:05 PM