protonscr

Root Constants issue

vkd3dclosed
HansKristian-Work/vkd3d-proton#1355 · opened 2022-12-26 by kingofthebongo2008 · updated 2023-01-12 · 7 comments · github
Kkingofthebongo2008 2022-12-26 github

Hello,
I have a signature which looks like this

#define MyRS_D3DStats "RootFlags( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT ), "
"CBV(b0, visibility = SHADER_VISIBILITY_VERTEX, flags = DATA_STATIC_WHILE_SET_AT_EXECUTE ), "
"RootConstants(num32BitConstants=8, b0, visibility = SHADER_VISIBILITY_PIXEL), "
"DescriptorTable(SRV(t0, numDescriptors = 1, flags = DATA_STATIC_WHILE_SET_AT_EXECUTE ), visibility = SHADER_VISIBILITY_PIXEL),"
"StaticSampler(s0, addressU = TEXTURE_ADDRESS_CLAMP, addressV = TEXTURE_ADDRESS_CLAMP, addressW = TEXTURE_ADDRESS_CLAMP, filter = FILTER_MIN_MAG_MIP_LINEAR )"

On load i get break point here in the spir converter:

if (member_index >= num_elements)
{
	LOGE("Root constant CBV is accessed out of bounds. (%u > %u).\n", member_index, num_elements);
	return false;
}

member index = 13,
num_elements = 10

if i increase the num32BitConstants to 16 or 32, it works
If i convert this to cbv works also

The shaders are compiled with dxc

  <ShaderModel>6.0</ShaderModel>
  <AdditionalOptions>-Zi -all_resources_bound -Fd %(Filename).pdb</AdditionalOptions>

The pixel shader which uses the root constans is:

struct LitMaterialPixel
{
float4 m_alpha_factor;
float4 m_texture_factor;
};

ConstantBuffer g_MaterialPixel : register(b0);

KK0bin 2022-12-26 github

Could you upload the problematic shader or a simplified version that reproduces the issue?

Kkingofthebongo2008 2022-12-26 github

This is the msbuild task which builds the shader, to h file, which is embedded into the executable

g_%(Filename) $(IntermediateOutputPath)\%(Filename).h RootSignature rootsig_1.1 g_%(Filename) $(IntermediateOutputPath)\%(Filename).h Vertex 6.0 -Zi -all_resources_bound -Fd %(Filename).pdb
</FxCompile>
g_%(Filename) $(IntermediateOutputPath)\%(Filename).h Pixel 6.0 -Zi -all_resources_bound -Fd %(Filename).pdb
Kkingofthebongo2008 2022-12-26 github

these are the two shaders, the problem first happens to the vertex shader, it does not get to the pixel shader,

proton version is from main pulled out two days ago

HHansKristian-Work maintainer 2023-01-05 github

I'll have a look, it might be possible that we don't properly check the stage visibility somewhere.

HHansKristian-Work maintainer 2023-01-05 github

I can reproduce it.

Nothing extracted yet.