Replies: 6 comments 21 replies
-
For buffer modes, you need to specify one when you create a buffer view, e.g. you are going to access the buffer through a shader view Structured buffers are buffers that consist of array of structures: StructuredBuffer<ParticleAttribs> g_Particles;
...
ParticleAttribs Particle = g_Particles[iParticleIdx]; Formatted buffers are accessed somewhat like 1D-textures. They allow format conversion when you read data from them (e.g. UNORM->FLOAT). As to the documentation, the most recent is in the header files. The one on the web site is quite out-dated. |
Beta Was this translation helpful? Give feedback.
-
Sorry to resurrect this older thread, but while working through some buffer layouts, I noticed that none of the sample projects use I also could not find any references to I have two buffers that are packed with float4 and int4, and I'm trying to figure out which buffer mode would work best for those. Would I just use undefined for these, since they are already in the expected format? Or is it more preferable/common to use a formatted buffer because it is packed with a small basic type? I tried to search online for related information, but found nothing on D3D12 and formatted buffers. |
Beta Was this translation helpful? Give feedback.
-
After getting things further along, I've run into another issue that has made me realize I apparently still don't understand the workflow to use dynamic buffers correctly in DX12 mode. I was under the impression that I could just map a dynamic buffer and leave it mapped indefinitely. But Diligent is throwing an error, reporting that the buffer contents have been discarded at the end of every frame. In.. What is the correct workflow for a dynamic buffer in DX12 for a buffer that is constantly re-used and rendered? Should I map it at the beginning of every frame, then unmap it before calling present? I think I read somewhere in the engine notes that it's better to not bother unmapping the buffer when working in newer APIs. Does this mean I call Sorry, for some reason, I can't seem to grasp the correct workflow/usage of dynamic buffers. Really appreciate any advice you can give me here. |
Beta Was this translation helpful? Give feedback.
-
Mapping it at the beginning of each frame, then unmapping at the end seems to work pretty well, but I'm running into a situation where, if I run out of buffer memory and restart the buffer iterator, it seems to ignore some of the data. I'm currently only writing onto 1/4th of the buffer at a time, rendering that, writing to the next 1/4th of it, rendering that, repeat, then loop back to zero when I reach the end, But as soon as my buffer write pointer loops back to zero, things start disappearing. I'm assuming this is because I shouldn't be looping back to memory that I've already submitted for rendering? If that is the case, how would I avoid writing onto dynamic memory that the GPU is still using? If I run out of dynamic buffer space, should I unmap/remap the buffer when I start back at zero? Will that be enough to stay in sync with the GPU? Edit: While doing some pure Dx12 reading, it looks like some developers do some type of double-buffering method for this situation. Basically they flip between 2 buffers, filling one while the GPU finishes with the other. They mention using fence/barriers to make sure the GPU finishes with the previous buffer before switching. I have to admit, resource states & fencing is not something I have a firm grasp on as of yet. I tried what I mentioned above, remapping the buffer when I run out of space, and it seems to work. But now I'm wondering why it works, unless its because Diligent is doing something in the background, such as waiting for the GPU to finish with the buffer? Edit 2: I just re-read the notes about tutorial 10, and it seems to answer most of my questions. From what I gather, remapping a dynamic buffer with |
Beta Was this translation helpful? Give feedback.
-
Thanks for the advice. Sorry to ask so many questions, but do you know if there is any way to query the maximum size of a dynamic buffer? I looked through the members of I was hoping that requesting a buffer that is too large would simply fail to create the buffer, so that I could detect that and reduce it. But DX12 seems to just entirely shut down the graphics device, making it pretty much impossible to recover from the situation. Through trial and error, it looks like 64MB might be the limit in my specific case, but I'm not sure if that is due to my card's specs, Diligent's inner workings, DX12, etc. |
Beta Was this translation helpful? Give feedback.
-
I know I've dragged this buffer conversion out far longer than it should be, but I have yet another question if you get a moment. I'm wondering what happens in the following scenario, with a structured buffer that contains arbitrary (non-vertex) data that is accessed by the vertex/pixel shaders (a shader resource buffer):
I'm a little unsure of weather this will work as expected, since you mentioned that all draw commands wait until the end of a frame to execute. Does this mean that half of the draw commands will be using one section of memory, while the other half will use another, even though they both expect to be using the same shader resource buffer? Or will this strategy fail to work, overwriting the shader's view of the buffer location when it is remapped, resulting in all draw commands using the contents of the second iteration and ignoring the first? |
Beta Was this translation helpful? Give feedback.
-
Hey, I'm new here. Still getting started with the API. I'm converting my engine from D3D9 to Diligent, and its going very well so far. I just had a question about Buffer Modes (Diligent::BUFFER_MODE). Can anyone help me understand what situations these would be used in? And/or what the purpose of using them are? I have not gotten far enough to start uploading custom data to shaders, so this may be why I don't yet understand these.
I may somewhat understand BUFFER_MODE_STRUCTURED. Would this be used to transmit data to the shader that contains typename elements in it? Is there any particular reason to use it instead of BUFFER_MODE_UNDEFINED? Is that reason just to make sure the shader can sort the data out correctly?
As for BUFFER_MODE_FORMATTED, I'm somewhat lost, but suspect it may have something to do with linking shader-based values? Again, what is the purpose of using this in place of undefined?
Lastly, is there any API documentation that's up to date? I found http://diligentgraphics.com/doc/index.html , but it appears to contain types that don't exist, and seems to be missing types that do. Also, the main page is showing up blank, so I'm not sure what version it relates to.
Thanks for any info!
Beta Was this translation helpful? Give feedback.
All reactions