[DX12] "const" in sm5.1 shaders

Started by
5 comments, last by Shnoutz 7 years, 10 months ago

Hello,

I have a vertex shader that looks like this:


struct Pixel
{
	float4 hposition : SV_Position;
	float2 texcoord : TexCoord;
};

Pixel vs_outputToScreen(uint index : SV_VertexID)
{
	float2 positions[4] =
	{
		float2(-1.0f, -1.0f),
		float2(-1.0f, 1.0f),
		float2(1.0f, -1.0f),
		float2(1.0f, 1.0f)
	};
	float2 texcoords[4] =
	{
		float2(0.0f, 1.0f),
		float2(0.0f, 0.0f),
		float2(1.0f, 1.0f),
		float2(1.0f, 0.0f)
	};
	Pixel pixel;
	pixel.hposition = float4(positions[index], 0, 1.0f);
	pixel.texcoord = texcoords[index];
	return pixel;
}

Granted its nothing spectacular...

If I add "const" to the declaration of "positions[4]" and "texcoords[4]", the shader still compiles but I get a crash when I try to build a pipeline state with it.

Here's the asm listing of both versions:

without "const" (14 instructions)


vs_5_1
dcl_globalFlags refactoringAllowed
dcl_input_sgv v0.x, vertex_id
dcl_output_siv o0.xyzw, position
dcl_output o1.xy
dcl_temps 1
dcl_indexableTemp x0[4], 4
dcl_indexableTemp x1[4], 4
mov x0[0].xy, l(-1.000000,-1.000000,0,0)
mov x0[1].xy, l(-1.000000,1.000000,0,0)
mov x0[2].xy, l(1.000000,-1.000000,0,0)
mov x0[3].xy, l(1.000000,1.000000,0,0)
mov x1[0].xy, l(0,1.000000,0,0)
mov x1[1].xy, l(0,0,0,0)
mov x1[2].xy, l(1.000000,1.000000,0,0)
mov x1[3].xy, l(1.000000,0,0,0)
mov r0.x, v0.x
mov o0.xy, x0[r0.x + 0].xyxx
mov o1.xy, x1[r0.x + 0].xyxx
mov o0.zw, l(0,0,0,1.000000)
ret 

with "const" (5 instructions)


vs_5_1
dcl_globalFlags refactoringAllowed
dcl_immediateConstantBuffer { { -1.000000, -1.000000, 0, 1.000000},
                              { -1.000000, 1.000000, 0, 0},
                              { 1.000000, -1.000000, 1.000000, 1.000000},
                              { 1.000000, 1.000000, 1.000000, 0} }
dcl_input_sgv v0.x, vertex_id
dcl_output_siv o0.xyzw, position
dcl_output o1.xy
dcl_temps 1
mov r0.x, v0.x
mov o0.xy, icb[r0.x + 0].xyxx
mov o0.zw, l(0,0,0,1.000000)
mov o1.xy, icb[r0.x + 0].zwzz
ret 

I should mention that the crash is only when I build on my laptop that is using a gtx970m. I get no crash on my desktop pc running a gtx680.

I have the validation layers on but the only thing I get is this:

"Exception thrown at 0x00007FFB043BF14C (D3D12.dll) in app.exe: 0xC0000005: Access violation reading location 0x0000000000000018"

Any ideas?

Advertisement

Same advice as before, does this go away with SM5.0?

Which version of the compiler are you using?

What about WARP?

hV1OgfD.png

Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group

SM5.0 is fine as well as warp.

Seems like I do not have the same compiler.

I have version :

10.0.10586.15

What does the call stack for the crash look like? Are the upper levels deep inside nv*.dll?

Are you on a pretty new NVIDIA driver?

Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group

The call stack looks like this:

D3D12.dll!00007ffb043bf14c() Unknown
igd12umd64.dll!00007ffae257dfcd() Unknown
D3D12.dll!00007ffb04366bcf() Unknown
D3D12.dll!00007ffb0436a12e() Unknown
D3D12.dll!00007ffb04368eb3() Unknown
d3d12SDKLayers.dll!00007ffaf789b724() Unknown
d3d12SDKLayers.dll!00007ffaf7895af8() Unknown
d3d12SDKLayers.dll!00007ffaf7885c09() Unknown
D3D12.dll!00007ffb0438d6db() Unknown
D3D12.dll!00007ffb0436daa8() Unknown
D3D12.dll!00007ffb0436de64() Unknown
d3d12SDKLayers.dll!00007ffaf788a28d() Unknown
...


I am using nvidia drivers 368.22 they look up to date.

igd12umd64 is the Intel HD Graphics driver, so your app isn't using the GTX 970m. What about your Intel graphics drivers?

Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group

Thats it!

I didn't know that was the signature of the Intel HD Graphics drivers.

I forced my nVidia driver to use the GTX 970m and the problem is fixed.

I haven't updated my Intel HD Graphics drivers for a while. (20.19.15.4331)

Ill update the Intel drivers and try again.

Edit:

The problem is fixed with Intel HD Graphics drivers (20.19.15.4424)

This topic is closed to new replies.

Advertisement