Advertisement

Shader doesn't work on AMD GPUs with latest driver

Started by April 04, 2019 03:01 PM
17 comments, last by Vilem Otte 5 years, 10 months ago
11 minutes ago, joeblack said:

What is format of texture ?

R32G32B32A32_FLOAT

11 minutes ago, joeblack said:

did you checked shader that is writing to it ?

They are correct. It works without scaling, i.e. if I don't use this shader and just use the full resolution position texture directly.

 


... 
  
SamplerState Sampler
{
	Filter = MIN_MAG_MIP_POINT;
	AddressU = Clamp;
	AddressV = Clamp;
};


...
  
	float2 TextureSize = float2(0, 0);
	positionTexture.GetDimensions(TextureSize.x, TextureSize.y);
	const uint Max = (1 << ScalingFlag) << ScalingFlag;
	uint UsedIndex = 0xFFFFFFFF;
	for (uint i = 0; i < Max && i < 16; ++i) {
		const uint3 CurrentTexCoords = TexCoords + uint3(i & ((1 << ScalingFlag) - 1), i >> ScalingFlag, 0);

		output.position = positionTexture.Sample(Sampler, (float2(CurrentTexCoords.xy)+0.5f)/ TextureSize);
		if (output.position.w >= 0.0f) {	
			UsedIndex = i;
			break;			
		}		
	}
	
	
...

With this change it works?!?

 

Edit: Adding [unroll] to the loop also fixes the problem. But why?

Well, i think that amd should answer that. at least you have workaround

Advertisement
1 hour ago, joeblack said:

at least you have workaround

Which costs like 10-20% performance (FPS)...

AMD has already fixed 2 driver bugs i had submitted in their forum. Usually they want a repo of your code so they can reproduce.

5 minutes ago, JoeJ said:

in their forum

Which forum? I've only found the DevGurus forums, are those the correct forums for that?

I'm not sure if I should give them access to my complete game code...

28 minutes ago, Magogan said:

DevGurus forums

Yes

28 minutes ago, Magogan said:

I'm not sure if I should give them access to my complete game code...

Yeah... unfortunately it is some work to strip it down so only the necessary things to show the bug remain. :|

Advertisement

Usualy it is unproper intitaion of texture/render target buffers, that some drivers omit and forgive, some do not. That is why I asked for how you establish your multiple render targets, and textures, how you set them for pipeline, do you check for available frame bufffer formats on device initiation etc.?

On 4/4/2019 at 8:44 PM, JoeJ said:

Yeah... unfortunately it is some work to strip it down so only the necessary things to show the bug remain. :|

Ideally you need to have the smallest source possible that reproduces the bug, pushing them whole code base is not going to work well. Also make sure to give them which version of driver was working, and which one did break it.

20 hours ago, JohnnyCode said:

Usualy it is unproper intitaion of texture/render target buffers, that some drivers omit and forgive, some do not.

From experience (and especially with Intel gpus and my work on our custom modified GTK+ where we use lots of OpenGL) - make sure to not just read articles but exact definitions of functions from the standard. NVidia tends to be the least forgiving, while AMD and Intel gpus tend to be much less forgiving and will give you an error each single time.

 

To the problem:

On 4/4/2019 at 6:40 PM, Magogan said:

Edit: Adding [unroll] to the loop also fixes the problem. But why?

There is major problem with loops in shader source code, as every shader compiler tries to optimize it out. When working with loops - it needs to determine whether you want to implement loop as actual loop (with condition and jump instructions - which is a standard way), or unroll the loop (and use multiple jumps just to break after i-th iteration if condition is satisfied).

In case of some loops the optimization may simple fail and give you incorrect results. If possible I recommend you give additional parameter do define whether you want to [unroll], [loop], [fastopt] and then there is another attribute for compute shaders [allow_uav_condition] (specifying [unroll] means that all other are ignored, also [loop] and [unroll] are mutually exclusive).

As you have 2 conditions in the loop, I assume that compiler simply failed to optimize your loop and produced invalid code. It is possible you received warning about it in the shader compilation output.

 

Can you try the same shader with [loop] attribute only?

My current blog on programming, linux and stuff - http://gameprogrammerdiary.blogspot.com

This topic is closed to new replies.

Advertisement