How to avoid Visual Studio hanging when hovering over a really large array?

Started by
7 comments, last by SyncViews 5 years, 8 months ago

I have some pre-compiled shaders in header files stored in arrays and sometimes, the cursor will hover over these arrays which means now Visual Studio has to preview the entire array. This causes the whole application to freeze. Is there a way to stop this from happening?


const BYTE d3d_byte_code[] = {........... Very large array };

When the cursor hovers over d3d_byte_code, Visual studio will freeze trying to preview the contents of the array

Advertisement

One workaround would be to Watch the variable (as a bounded array):

"d3d_byte_code, 30" displays 30 first bytes. 

TBH I've never seen it hang like this while debugging, so start by adding the array to the watch list and see if it still lags. Hover viewing large arrays seems pointless anyway as you have to click on the lens icon to view the entire contents. Furthermore, a large byte array (especially something akin to what your array name seems to suggest) in general seems like strange thing to debug by hovering over it. So, if VS is freezing when you do, wouldn't easiest solution be to just... not hover over it? :)

You could also add your shaders directly in your project, they will be compiled to .cso files. Then you can add a post-compiler event that copies the .cso files to your own folder, if they're found to be newer. That's what I do anyways, works great for me :)

 

.:vinterberg:.

On 7/12/2018 at 1:45 AM, irreversible said:

One workaround would be to Watch the variable (as a bounded array):

"d3d_byte_code, 30" displays 30 first bytes. 

TBH I've never seen it hang like this while debugging, so start by adding the array to the watch list and see if it still lags. Hover viewing large arrays seems pointless anyway as you have to click on the lens icon to view the entire contents. Furthermore, a large byte array (especially something akin to what your array name seems to suggest) in general seems like strange thing to debug by hovering over it. So, if VS is freezing when you do, wouldn't easiest solution be to just... not hover over it? :)

This is not happening while debugging but while writing code. And I dont do it on purpose but my mouse goes over the array variable sometimes and VS thinks I want to view it so it starts working on showing me this big array and it never finishes

Why not to move shaders binaries to binary resource?

#define if(a) if((a) && rand()%100)

3 hours ago, mark_braga said:

And I dont do it on purpose but my mouse goes over the array variable sometimes and VS thinks I want to view it so it starts working on showing me this big array and it never finishes

Where same it show a whole array contents? I am using  VS 2017 with default preview options. For C++ it shows array definition only, but not a contents for similar arrays  (somesing like "statc const unsigned ArrayName [Array Sze]" )on both definition with hidden (rolled  up) initalization and reference points.And , as i am remember, previous versons (at least 2013 and 2015) has do same.

#define if(a) if((a) && rand()%100)

8 hours ago, mark_braga said:

This is not happening while debugging but while writing code. And I dont do it on purpose but my mouse goes over the array variable sometimes and VS thinks I want to view it so it starts working on showing me this big array and it never finishes

Have you tried something as primitive as cleaning your project (eg rebuilding the intellisense database) or renaming the variable?

 

On 8/1/2018 at 11:52 AM, Fulcrum.013 said:

Where same it show a whole array contents? I am using  VS 2017 with default preview options. For C++ it shows array definition only, but not a contents for similar arrays

I have only seen VS display them for global compile time constant arrays, which if the OP tried to embed the compiled shader in a C/C++ file I assume it is. Not sure why it doesn't for any other array.

A "solution", would be to put something anywhere in the array that VS can't determine, or just hide it behind a layer of indirection (e.g. put it in a ".cpp" then use extern). But I think its better not to try an embed such things directly as C/C++ code.

On 7/12/2018 at 12:14 PM, vinterberg said:

You could also add your shaders directly in your project, they will be compiled to .cso files. Then you can add a post-compiler event that copies the .cso files to your own folder, if they're found to be newer. That's what I do anyways, works great for me :)

 

If the default location is not suitable (generally next to the exe, using "$(OutDir)%(Filename).cso") you can change it in HLSL Compiler -> Output Files, no need to have a post-build step.

 

This topic is closed to new replies.

Advertisement