Advertisement
Guest User

Untitled

a guest
Jun 26th, 2012
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.23 KB | None | 0 0
  1. 09:04 < danzel> TomSpilman: are you around? need some advice on making Vertex/Index buffer not suck on PSS
  2. 09:05 < TomSpilman> i am now
  3. 09:05 < danzel> awesome :)
  4. 09:05 < TomSpilman> whats up?
  5. 09:06 < danzel> So for DynamicVertexBuffer I should be able to implement it as you suggested on codeplex
  6. 09:06 < danzel> which is basically what I have implemented for Vertex+IndexBuffer at the moment
  7. 09:06 < danzel> but I assume, for Vertex+IndexBuffer I don't want to keep copying the data to hardware every frame
  8. 09:06 < danzel> as they'll most likely be static
  9. 09:07 < danzel> (On PSS we have a native VertexBuffer - PssVertexBuffer - which is a vertex and index buffer)
  10. 09:07 < danzel> so getting that to work with XNA is a bit hard as we have separate vertex and index buffer objects
  11. 09:08 < danzel> so at the moment i've made XNA Vertex/Index buffer copy the data given to them to an array
  12. 09:08 < danzel> then when you go to draw using them we do what you've suggested for DynamicVertexBuffer
  13. 09:08 < TomSpilman> that seems appropriate
  14. 09:08 < danzel> and get a PssVB from the pool, set the data etc
  15. 09:08 < TomSpilman> not sure how optimal it is
  16. 09:09 < TomSpilman> but using an array in system memory to fake a dynamic VB isn't that strange
  17. 09:09 < danzel> yeah, it'll work, but probably isn't very good if you have static 3d models etc
  18. 09:09 < TomSpilman> right
  19. 09:09 < danzel> the copy to an internal array part i'm happy with
  20. 09:10 < danzel> but uploading from that array to a hardware VB each frame seems like a waste
  21. 09:11 < danzel> but i've been having trouble figuring out how to do just one upload due to being able use the same VB
  22. and change IB
  23. 09:11 < danzel> do you think I probably need to care? Or should we just live with uploading them every time they are
  24. used?
  25. 09:11 < danzel> I hope i've explained myself well enough
  26. 09:15 < TomSpilman> so i wouldn't upload it every frame
  27. 09:15 < TomSpilman> i would keep track of if its "dirty"
  28. 09:15 < TomSpilman> if someone changes a vert or index... mark things as dirty
  29. 09:15 < TomSpilman> then update... clear the dirty flag
  30. 09:16 < TomSpilman> statics then should be one update for the most part
  31. 09:16 < danzel> cool, that was my thoughts to
  32. 09:16 < TomSpilman> dynamics update at whatever rate they update
  33. 09:16 < TomSpilman> if you want to get trickier
  34. 09:16 < danzel> thoughts on how to handle that with the IB/VB->PssVB split
  35. 09:16 < TomSpilman> you can keep track of the "dirty range"
  36. 09:16 < danzel> since you could render a VB with 2 different IBs
  37. 09:16 < TomSpilman> the min/max vert/index that changed
  38. 09:16 < TomSpilman> then only update that sub-range
  39. 09:17 < TomSpilman> yea... that is trickier
  40. 09:17 < TomSpilman> i see two options
  41. 09:18 < danzel> It probably wouldn't happen often I'd assume, so we could probably keep track of the the last IB that
  42. was used with a VB and re-upload the IB if it changed?
  43. 09:18 < TomSpilman> one... have one "real" PSSVertexBuffer... for each XNA IndexBufffer + VertexBuffer combination
  44. 09:19 < TomSpilman> right... or that option... have on PSSVertexBuffer for each XNA VertexBuffer... update the index
  45. data every draw if it changes
  46. 09:19 < TomSpilman> its pretty unfortunate how they structured the PSS api for that
  47. 09:19 < danzel> yeah :/
  48. 09:20 < TomSpilman> under the hood i assure you they are uploading index and vertex buffers seperately
  49. 09:20 < TomSpilman> this is them trying to "optimize" stuff for you when its not needed
  50. 09:20 < danzel> yeah, there are separate calls for setting each of them, so i'd expect so
  51. 09:21 < TomSpilman> technically there is no reason why they couldn't offer 3 objects... PSSVertexBuffer,
  52. PSSIndexBuffer, PSSVertexIndexBuffer
  53. 09:21 < TomSpilman> i would keep bitching at them about that one and hope they correct their mistake
  54. 09:27 < danzel> have added a request, cheers
  55. 09:27 < TomSpilman> cool
  56. 09:28 < danzel> If i'm going to implement having one PssVertexBuffer for each XNA IB+VB combo, how would you recommend
  57. structuring this? Have a Dictionary<IB,PssVB> in VertexBuffer or something else?
  58. 09:29 < TomSpilman> you could do it like that for sure
  59. 09:30 < TomSpilman> gets rid of the issue of needing to make a key from IB+VB
  60. 09:30 < TomSpilman> and would be pretty simple
  61. 09:30 < TomSpilman> in most cases the dictionary would have one element
  62. 09:30 < danzel> yep
  63. 09:31 < TomSpilman> you would just need to be sure to clean up the dictionary when the VB is disposed
  64. 09:31 < TomSpilman> and of course all this would be done using internal APIs and no one from the outside would see it
  65. 09:32 < TomSpilman> just like we do with the various state objects in GraphicsDevice
  66. 09:33 < TomSpilman> when you do GraphicsDevice.VertexBuffer = foo; or .IndexBuffer = bar;
  67. 09:33 < TomSpilman> you don't really do anything... you just hold on to the current vb and ib
  68. 09:33 < TomSpilman> its when you go to draw that #if PSS code kicks in and passes the IB to the VB to get a PSSVB back
  69. 09:34 < TomSpilman> then that is set
  70. 09:34 < TomSpilman> look at how i setup the Raster/DepthSencil/BlendState stuff or the UserPrim stuff
  71. 09:35 < TomSpilman> should be a good guide as to how your system could work
  72. 09:36 < danzel> alright awesome thanks
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement