DirectXShaderCompiler
DirectXShaderCompiler copied to clipboard
Linker doesn't strip resource names when using -Qstrip_reflect
Description The linker keeps resource names in DXIL reflection even when the -Qstrip_reflect is used. Compiling lib_6_3 targets also leaves the resource names in too, so there doesn't appear to be any way to remove them.
Steps to Reproduce Run this:
void ReflStripBugTest(IDxcCompiler3* aCompiler, IDxcLinker* aLinker)
{
const char* sourceBlob =
"Texture2D<uint> texResource : register(t900);\n"
"RWTexture2D<uint> rwTexResource[] : register(u0, space2400);\n"
"[numthreads(8, 8, 1)]\n"
"void main(uint3 dtid : SV_DispatchThreadID, uint3 gtid : SV_GroupThreadID, uint3 gid : SV_GroupID, uint gindex : SV_GroupIndex)\n"
"{\n"
" rwTexResource[0][dtid.xy] = texResource.Load(dtid.xyz);\n"
"}\n";
DxcBuffer sourceBuffer;
sourceBuffer.Encoding = DXC_CP_ACP;
sourceBuffer.Ptr = sourceBlob;
sourceBuffer.Size = strlen(sourceBlob);
const wchar_t* compileArgs[] = {
L"-O3",
L"-T",
L"lib_6_3",
L"-Qstrip_reflect",
};
IDxcResult* result;
aCompiler->Compile(&sourceBuffer, compileArgs, sizeof(compileArgs) / sizeof(compileArgs[0]), nullptr, IID_PPV_ARGS(&result));
IDxcBlob* compiledBlob = nullptr;
result->GetResult(&compiledBlob);
const wchar_t* libName = L"MyLibrary";
aLinker->RegisterLibrary(libName, compiledBlob);
const wchar_t* linkArgs[] = {
L"-O3",
L"-Qstrip_reflect",
};
IDxcOperationResult* linkResult = nullptr;
aLinker->Link(L"main", L"cs_6_3", &libName, 1, linkArgs, sizeof(linkArgs) / sizeof(linkArgs[0]), &linkResult);
IDxcBlob* linkedBlob = nullptr;
linkResult->GetResult(&linkedBlob);
const void* linkedData = linkedBlob->GetBufferPointer();
size_t linkedDataSize = linkedBlob->GetBufferSize();
IDxcResult* disasmResult = nullptr;
DxcBuffer linkedBuffer;
linkedBuffer.Encoding = DXC_CP_ACP;
linkedBuffer.Ptr = linkedBlob->GetBufferPointer();
linkedBuffer.Size = linkedBlob->GetBufferSize();
aCompiler->Disassemble(&linkedBuffer, IID_PPV_ARGS(&disasmResult));
IDxcBlob* disasmBlob = nullptr;
disasmResult->GetResult(&disasmBlob);
const char* disasmText = static_cast<const char*>(disasmBlob->GetBufferPointer());
puts(disasmText);
}
Actual Behavior Disassembly contains the resource names in the metadata.
Environment
- DXC version dxcompiler.dll: 1.7 - 1.7.2308.7 (69e54e290); dxil.dll: 1.7(101.7.2308.12)
- Host Operating System Windows 10