Skip to content

Shader compilation fails when file path has utf8 characters #7394

@Sinamore

Description

@Sinamore

Description

Shader compilation fails when file path has utf8 characters (Cyrillic, Korean, ... in our case username is part of the path).

We use dxc as a shared library to generate shaders in multi-threaded context.
That's how our CompileShader function is structured:

#include "dxcapi.h"

bool CompileShader( CStringView Source, ... )
{
    CComPtr<IDxcLibrary> Library;
    HRESULT hr = DxcCreateInstance( CLSID_DxcLibrary, IID_PPV_ARGS( &Library ) );
    ...
    CComPtr<IDxcCompiler3> Compiler;
    hr = DxcCreateInstance( CLSID_DxcCompiler, IID_PPV_ARGS( &Compiler ) );
    ...
    DxcBuffer SourceBuffer {};
    SourceBuffer.Ptr = Source.GetData();
    SourceBuffer.Size = Source.GetSize();
    SourceBuffer.Encoding = DXC_CP_ACP;

    CComPtr<IDxcResult> Result;
    hr = Compiler->Compile( &SourceBuffer, Args.AccessData(), Args.GetSize(), nullptr, IID_PPV_ARGS( &Result ) );
    ...
}

Source contains shader source code, I've checked that it has only ASCII characters.
Args is an array that contains <source file path>/<filename>.scache -spirv -fvk-b-shift 0 all -fvk-t-shift 0 all -fvk-s-shift 0 all -fvk-u-shift 0 all -fvk-auto-shift-bindings -fvk-use-dx-layout -HV 2021 -fspv-target-env=vulkan1.1 -T cs_6_0.

Steps to Reproduce
Compile any shader with the CompileShader above.

Actual Behavior

On Windows: hr is E_FAIL and Result contains "error: error reading '/000000005dcd549100000000.scache", even though the file exists in the folder.

On Linux: hr is E_FAIL and Result contains "Internal compiler error:" (See next post for more info)

Environment

  • DXC version 1.8.2407 and 1.8.2502
  • Host Operating System Windows 11 and Ubuntu 24.04.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug, regression, crash

    Type

    No type

    Projects

    Status

    Triaged

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions