Description

This is a path specification problem, so if the correct path is given, the DLL will load correctly.

static void DumpShaderAsm(FString& String, const D3D12_SHADER_BYTECODE& Shader)
{
#if D3D12RHI_USE_D3DDISASSEMBLE
	if (Shader.pShaderBytecode)
	{
		// This function needs to load the bundled version of d3dcompiler lib explictly. Implicit linking results
		// in picking up the system lib by both the engine and SCWs (which links to this module), which makes
		// the shader compilation system-dependent.
		static pD3DDisassemble D3DDisasmFunc = nullptr;
		if (D3DDisasmFunc == nullptr)
		{
			static HMODULE CompilerDLL = NULL;	// not nullptr as the return value of LoadLibrary remains defined as NULL
#if 0
			static const TCHAR* CompilerPath = TEXT("Binaries/ThirdParty/Windows/DirectX/x64/d3dcompiler_47.dll");
			if (CompilerDLL == NULL)
			{
				CompilerDLL = LoadLibrary(CompilerPath);
			}
#else
			if (CompilerDLL == NULL)
			{
				FString CompilerPath = FPaths::EngineDir();
				CompilerPath.Append(TEXT("Binaries/ThirdParty/Windows/DirectX/x64/d3dcompiler_47.dll"));
				CompilerDLL = LoadLibrary(*CompilerPath);
			}
#endif
Steps to Reproduce
  1. Edit shader file to cause pipeline state compilation errors (semantic mismatch will do that)
    Example: ScreenPass.usf
    // Copyright Epic Games, Inc. All Rights Reserved.
    
    #include "Common.ush"
    
    Texture2D InputTexture;
    SamplerState InputSampler;
    
    void ScreenPassVS(
    	in float4 InPosition : ATTRIBUTE0,
    	in float2 InTexCoord : ATTRIBUTE1,
    //	out noperspective float4 OutUVAndScreenPos : TEXCOORD0,	//comment out
    	out noperspective float4 OutUVAndScreenPos : TEXCOORD2, //add this line
    	out float4 OutPosition : SV_POSITION)
    {
    	DrawRectangle(InPosition, InTexCoord, OutPosition, OutUVAndScreenPos);
    }
    ...
    
  2. launch the editor with a project
    *If you want to set breakpoints, put pragma optimize around DumpShaderAsm or  DebugEditor build is better.

Result :
DumpShaderAsm fails to load d3dcompiler_47.dll. So the engine will not output disassemble code in the log

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-186891 in the post.

0
Login to Vote

Fixed
ComponentUE - Rendering Architecture
Affects Versions5.15.2
Target Fix5.3
Fix Commit25731620
Main Commit25731704
CreatedMay 24, 2023
ResolvedJun 1, 2023
UpdatedAug 21, 2023
View Jira Issue