Primitives scrambled when vertex buffer becomes "large"

Started by
8 comments, last by Picaro 8 years, 10 months ago

Hello! I am hoping that someone may be able to help me with this, I have had no luck searching through the internet. I have been reading Frank Luna's book "3D game programming with DirectX 11". All going well, except when I got to the point where I load up a skull from file and the vertex buffer seemed to become to large - but in case someone is reading this who is not familiar with that book, I narrowed the problem down to it's bare bones. I follow an algorithm that creates some hills - as in Franks book it is just a grid that has as y-coordinates a function of cosines. If I make the grid say 100 by 100, and this 10000 points it looks fine. If however I try to increase the detail, and say try to make a grid of 300 by 300, then the grid ends up being, for want of a better way of putting it, completely messed up - it looks like triangles are jumbled up, some taking coordinates from almost random places, if I load up a skull shape for example, it almost looks like bits of skull are connecting to bits of hill. I notice that if I make my vertex buffer objects a bit smaller, for example get rid of the .Color part of it, then I can draw the hills and skull successfully, but if I increase the detail further, then again everything gets messed up, so I am inclined to believe that the problem has something to do with the amount of memory taken up by the vertex buffer. I have a simple example that reproduces the problem, a c++ visual studio solution file. I tried getting this answered on stackoverflow.com, but got firmly knocked back because it apparently is a great sin to suggest supplying code, I wanted to supply the solution because there is no obvious 10 lines of code that are wrong to me. I have attached the visual studio solution, to reproduce the bug, search for "showBug" and set to true (or false to hide it!).[attachment=27650:BackgammonDesktop.zip]

Cheers!

Advertisement

Are your index buffers 16 bit only? If so, try using 32 bit indices instead. (300*300 ~ 90000 while 16 bit index can hold a max value of around 65000 - maximum map size that works would be around 250*250)

o3o

Waterlimon's comment appears to be spot on.

Also, do you have the debug layer enabled? If not, do so. If so, what does it tell you?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Hello! thanks for your reply, I tried changing a line as follows:

m_pImmediateContext->IASetIndexBuffer(m_pIndexBuffer, DXGI_FORMAT_R16_UINT, 0);

to

m_pImmediateContext->IASetIndexBuffer(m_pIndexBuffer, DXGI_FORMAT_R32_UINT, 0);

this caused a change but didn't appear to fix it, although what you describe really sounds like it is on the right track because what you describe almost exactly describes the boundary between the bug appearing and not appearing.

Thanks for your reply, the debug log doesn't seem to show anything strange (?)

'BackgammonDesktop.exe' (Win32): Loaded 'C:\Users\Peter\Desktop\BackgammonDesktop\BackgammonDesktop\Debug\BackgammonDesktop.exe'. Symbols loaded.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\apphelp.dll'. Cannot find or open the PDB file.
SHIMVIEW: ShimInfo(Complete)
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\d3d11.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp120d.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120d.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dxgi.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\nvinit.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\bcryptprimitives.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Program Files (x86)\NVIDIA Corporation\coprocmanager\detoured.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Program Files (x86)\NVIDIA Corporation\coprocmanager\Nvd3d9wrap.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\setupapi.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Program Files (x86)\NVIDIA Corporation\coprocmanager\nvdxgiwrap.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\uxtheme.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\combase.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\PROGRA~2\McAfee\SITEAD~1\sahook.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleaut32.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dwmapi.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel.appcore.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dxgidebug.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\nvumdshim.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\igd10umd32.dll'. Cannot find or open the PDB file.
'BackgammonDesktop.exe' (Win32): Loaded 'C:\Windows\SysWOW64\d3d11_2sdklayers.dll'. Cannot find or open the PDB file.
The thread 0x26c8 has exited with code 0 (0x0).
'BackgammonDesktop.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\igd10umd32.dll'
The program '[8168] BackgammonDesktop.exe' has exited with code 0 (0x0).

My mistake, I also changed the "WORD"s to "DWORD"s and now it works, thanks very much for your help Waterlimon and Buckeye


I also changed the "WORD"s to "DWORD"s

Thanks for posting the complete fix.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Hi Buckeye, should i attach the fixed VS solution? I am new here and not sure what the etiquette is... Cheers!
That is not necessary.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

That is not necessary.L. Spiro


Good good! :-)

Cheers

This topic is closed to new replies.

Advertisement