@@ -237,6 +237,10 @@ class PixTest {
237
237
TEST_METHOD (DxcPixDxilDebugInfo_StructContainedResource)
238
238
TEST_METHOD (DxcPixDxilDebugInfo_StructStaticInit)
239
239
TEST_METHOD (DxcPixDxilDebugInfo_StructMemberFnFirst)
240
+ TEST_METHOD (DxcPixDxilDebugInfo_UnnamedConstStruct)
241
+ TEST_METHOD (DxcPixDxilDebugInfo_UnnamedStruct)
242
+ TEST_METHOD (DxcPixDxilDebugInfo_UnnamedArray)
243
+ TEST_METHOD (DxcPixDxilDebugInfo_UnnamedField)
240
244
241
245
TEST_METHOD (VirtualRegisters_InstructionCounts)
242
246
TEST_METHOD (VirtualRegisters_AlignedOffsets)
@@ -250,6 +254,9 @@ class PixTest {
250
254
dxc::DxcDllSupport m_dllSupport;
251
255
VersionSupportInfo m_ver;
252
256
257
+ void PixTest::TestUnnamedTypeCase (const char *hlsl,
258
+ const wchar_t *expectedTypeName);
259
+
253
260
void CreateBlobPinned (_In_bytecount_(size) LPCVOID data, SIZE_T size,
254
261
UINT32 codePage, _Outptr_ IDxcBlobEncoding **ppBlob) {
255
262
CComPtr<IDxcLibrary> library;
@@ -3048,6 +3055,155 @@ void main()
3048
3055
VERIFY_IS_TRUE (FoundTheStruct);
3049
3056
}
3050
3057
3058
+ void PixTest::TestUnnamedTypeCase (const char * hlsl, const wchar_t * expectedTypeName) {
3059
+ if (m_ver.SkipDxilVersion (1 , 2 ))
3060
+ return ;
3061
+ auto dxilDebugger = CompileAndCreateDxcDebug (hlsl, L" cs_6_0" );
3062
+ auto liveVariables =
3063
+ GetLiveVariablesAt (hlsl, " InterestingLine" , dxilDebugger);
3064
+ DWORD count;
3065
+ VERIFY_SUCCEEDED (liveVariables->GetCount (&count));
3066
+ bool FoundTheVariable = false ;
3067
+ for (DWORD i = 0 ; i < count; ++i) {
3068
+ CComPtr<IDxcPixVariable> variable;
3069
+ VERIFY_SUCCEEDED (liveVariables->GetVariableByIndex (i, &variable));
3070
+ CComBSTR name;
3071
+ variable->GetName (&name);
3072
+ if (0 == wcscmp (name, L" glbl" )) {
3073
+ FoundTheVariable = true ;
3074
+ CComPtr<IDxcPixType> type;
3075
+ VERIFY_SUCCEEDED (variable->GetType (&type));
3076
+ CComBSTR typeName;
3077
+ VERIFY_SUCCEEDED (type->GetName (&typeName));
3078
+ VERIFY_ARE_EQUAL (typeName, expectedTypeName);
3079
+ break ;
3080
+ }
3081
+ }
3082
+ VERIFY_IS_TRUE (FoundTheVariable);
3083
+ }
3084
+
3085
+ TEST_F (PixTest, DxcPixDxilDebugInfo_UnnamedConstStruct) {
3086
+ const char *hlsl = R"(
3087
+ RWStructuredBuffer<float> floatRWUAV: register(u0);
3088
+
3089
+ [numthreads(1, 1, 1)]
3090
+ void main()
3091
+ {
3092
+ const struct
3093
+ {
3094
+ float fg;
3095
+ RWStructuredBuffer<float> buf;
3096
+ } glbl = {42.f, floatRWUAV};
3097
+
3098
+ float f = glbl.fg + glbl.buf[1]; // InterestingLine
3099
+ floatRWUAV[0] = f;
3100
+ }
3101
+
3102
+ )" ;
3103
+
3104
+ TestUnnamedTypeCase (hlsl, L" const <unnamed>" );
3105
+ }
3106
+
3107
+ TEST_F (PixTest, DxcPixDxilDebugInfo_UnnamedStruct) {
3108
+ const char *hlsl = R"(
3109
+ RWStructuredBuffer<float> floatRWUAV: register(u0);
3110
+
3111
+ [numthreads(1, 1, 1)]
3112
+ void main()
3113
+ {
3114
+ struct
3115
+ {
3116
+ float fg;
3117
+ RWStructuredBuffer<float> buf;
3118
+ } glbl = {42.f, floatRWUAV};
3119
+ glbl.fg = 41.f;
3120
+ float f = glbl.fg + glbl.buf[1]; // InterestingLine
3121
+ floatRWUAV[0] = f;
3122
+ }
3123
+
3124
+ )" ;
3125
+
3126
+ TestUnnamedTypeCase (hlsl, L" <unnamed>" );
3127
+ }
3128
+
3129
+ TEST_F (PixTest, DxcPixDxilDebugInfo_UnnamedArray) {
3130
+ const char *hlsl = R"(
3131
+ RWStructuredBuffer<float> floatRWUAV: register(u0);
3132
+
3133
+ [numthreads(1, 1, 1)]
3134
+ void main()
3135
+ {
3136
+ struct
3137
+ {
3138
+ float fg;
3139
+ RWStructuredBuffer<float> buf;
3140
+ } glbl[2] = {{42.f, floatRWUAV},{43.f, floatRWUAV}};
3141
+ float f = glbl[0].fg + glbl[1].buf[1]; // InterestingLine
3142
+ floatRWUAV[0] = f;
3143
+ }
3144
+
3145
+ )" ;
3146
+
3147
+ TestUnnamedTypeCase (hlsl, L" <unnamed>[]" );
3148
+ }
3149
+
3150
+ TEST_F (PixTest, DxcPixDxilDebugInfo_UnnamedField) {
3151
+ const char *hlsl = R"(
3152
+ RWStructuredBuffer<float> floatRWUAV: register(u0);
3153
+
3154
+ [numthreads(1, 1, 1)]
3155
+ void main()
3156
+ {
3157
+ struct
3158
+ {
3159
+ struct {
3160
+ float fg;
3161
+ RWStructuredBuffer<float> buf;
3162
+ } contained;
3163
+ } glbl = { {42.f, floatRWUAV} };
3164
+ float f = glbl.contained.fg + glbl.contained.buf[1]; // InterestingLine
3165
+ floatRWUAV[0] = f;
3166
+ }
3167
+
3168
+ )" ;
3169
+
3170
+ if (m_ver.SkipDxilVersion (1 , 2 ))
3171
+ return ;
3172
+ auto dxilDebugger = CompileAndCreateDxcDebug (hlsl, L" cs_6_0" );
3173
+ auto liveVariables =
3174
+ GetLiveVariablesAt (hlsl, " InterestingLine" , dxilDebugger);
3175
+ DWORD count;
3176
+ VERIFY_SUCCEEDED (liveVariables->GetCount (&count));
3177
+ bool FoundTheVariable = false ;
3178
+ for (DWORD i = 0 ; i < count; ++i) {
3179
+ CComPtr<IDxcPixVariable> variable;
3180
+ VERIFY_SUCCEEDED (liveVariables->GetVariableByIndex (i, &variable));
3181
+ CComBSTR name;
3182
+ variable->GetName (&name);
3183
+ if (0 == wcscmp (name, L" glbl" )) {
3184
+ CComPtr<IDxcPixType> type;
3185
+ VERIFY_SUCCEEDED (variable->GetType (&type));
3186
+ CComPtr<IDxcPixStructType> structType;
3187
+ VERIFY_SUCCEEDED (type->QueryInterface (IID_PPV_ARGS (&structType)));
3188
+ DWORD fieldCount = 0 ;
3189
+ VERIFY_SUCCEEDED (structType->GetNumFields (&fieldCount));
3190
+ VERIFY_ARE_EQUAL (fieldCount, 1 );
3191
+ // Just a crash test:
3192
+ CComPtr<IDxcPixStructField> structField;
3193
+ structType->GetFieldByName (L" " , & structField);
3194
+ VERIFY_SUCCEEDED (structType->GetFieldByIndex (0 , &structField));
3195
+ FoundTheVariable = true ;
3196
+ CComPtr<IDxcPixType> fieldType;
3197
+ VERIFY_SUCCEEDED (structField->GetType (&fieldType));
3198
+ CComBSTR typeName;
3199
+ VERIFY_SUCCEEDED (fieldType->GetName (&typeName));
3200
+ VERIFY_ARE_EQUAL (typeName, L" <unnamed>" );
3201
+ break ;
3202
+ }
3203
+ }
3204
+ VERIFY_IS_TRUE (FoundTheVariable);
3205
+ }
3206
+
3051
3207
CComPtr<IDxcBlob> PixTest::RunShaderAccessTrackingPass (IDxcBlob *blob) {
3052
3208
CComPtr<IDxcOptimizer> pOptimizer;
3053
3209
VERIFY_SUCCEEDED (
0 commit comments