register(s0) does nothing

I have rewatched MVA Advanced Monogame video for two times to get understanding why

sampler TextureSampler : register(s0); 

doesn’t work for me(texture doesn’t bind resulting in returning 0,0,0,0 by tex2D). Trying to draw a quad instead of using sprite batch and setting


doesn’t bind texture too. Everything else in shader runs fine.
But specifying texture by setting value in effect parameter makes texture appear. Magic.
Attempting to convert the shader to this approach MGFX weirdness when adjusting texCoord doesn’t help too.
Using MonoGame 3.3, DirectX, Windows Desktop. Are there any known bugs/regressions regarding this? If no - is there a full example with working “: register(s0);”?

are you writing directly to the backbuffer or to a rendertarget?

I tried everything. Actually I resorted to Darwinian programming by adding/removing everything randomly until it started to work and found it is actually usability problem within documentation and content pipeline :confused:
:register(s0) only works with specific pixel program:

float4 PixelShaderFunction(float4 position : SV_Position, float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0{...}

And silently fails to compile ‘register(s0)’ part if some of arguments are omitted.
This should be written in red in the docs :smile:

if you are using a spritebatch, register S0 gets clobbered by the texture being rendered

Actually I wanted it to be ‘clobbered’ by SpriteBatch textures, but it fails to bind it if pixel shader has non-complete definition. Actually it might be deeper that this, but still, I have made a PR to add this observation to docs:

I think I ran into this exact issue, and I see a few unresolved threads about it. There’s a workaround that involves just passing in textures as regular parameters without using registers, but did anyone understand the exact fix described here based on how the effect is compiled?

EDIT: This was with loading a raw fx file through the content manager. I can try running it through 2MGFX tomorrow to see if there’s a difference.