About arrays in shaders

Hi !
Is there a special way of declaring a “global” array in a shader ?
My shader fails to load ingame with builds > 3.7.1248 saying the key is already existing (cf https://github.com/MonoGame/MonoGame/issues/6184)
As no one has bumped on this issue, I’m just wondering what’s wrong since 3.7.1248+

When I do

	#define VS_SHADERMODEL vs_3_0
	#define PS_SHADERMODEL ps_3_0
	#define VS_SHADERMODEL vs_5_0
	#define PS_SHADERMODEL ps_5_0

//21 values
//Breaklines are here for purpose, but removing them gives the same result: exception
float weights[] = { 0.051f, 0.1f, 0.15f, 0.28f, 0.5f,
0.7f, 0.8f, 0.9f, 1.0f, 1.0f, 
1.0f, 1.0f, 1.0f, 0.9f, 0.8f, 
0.7f, 0.5f, 0.28f, 0.15f, 0.1f,
0.051f }; //uniform, or const changes nothing

Even a simple

uniform float weights[KERNEL_SIZE];
uniform float2 offsets[KERNEL_SIZE];

gives this Exception… Putting static instead of uniform allows to load the effect, but effectparameters are null and when setting value, the game throws a nullexception !

I was wondering if it is a true bug of MG, or if I missed something in an update, changing the way of declaring an array ?
Thanks for any clue on this.

Just saw your issue on github.
Sorry for the delay. Will look into it.

Committed a PR

Great! I hope it will be merged soon, thanks

It’s been merged already. Could you try it in the newest develop build?

I’m building content, I’ll be able to test it in a few minutes :wink:

EDIT: It works :slight_smile:

:dancer: YAY! :confetti_ball:
Then I can begin to fix this correctly tomorrow :slight_smile:

1 Like

Hey @Alkher!
You did a really nice job searching for the bug, which was no easy find. Congrats.
Just saying.

Thanks :wink: I like to get to the bottom of things when I don’t understand something or have a problem. I’m not the kind of “it just does not work” :stuck_out_tongue:
When I have time I’ll continue to debug and give feedback about why there are null (if I find something interesting), or test your PRs if any

Nice. My family is sick now… All of them… So I’ll fall asleep in a few minutes (19:15 here in Austria). No programming today :cry:

Sorry to hear that. I hope you’ll all recover soon.
I’ve not been able to investigate a lot, I lost my internet connection due to gust :frowning:
I’ll continue in a few hours as it is back now.