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