HLSL in Resource Files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Robert Varga
    New Member
    • Apr 2010
    • 1

    HLSL in Resource Files

    Hi,
    I'am developing some application and since I want to create first public release, I am trying to include all resource files (bmps, dlls and so on) into EXE.

    The problem is that I have one *.hlsl shader file whitch compiles always on app build. I've tried to put this *.hlsl file into "Resource Files" folder in project, then F5 (build, release, start app), and then I copied just an *.exe file to other directory, where *.hlsl file isn't. Crash...

    Application cannot start without *.hlsl file just in same folder as *.exe file is. Whats the problem? Included dll files, icos, bmps works well.

    It crashes on these lines where I am trying to load *.hlsl file...

    Code:
    test = D3DX11CompileFromFile( L"nameof.hlsl",NULL, NULL, "nameofproc", "cs_5_0", dwShaderFlags, NULL, NULL, &pPSBuf, NULL, NULL );
    test = g_pd3dDevice->CreateComputeShader( ( DWORD* )pPSBuf->GetBufferPointer(), pPSBuf->GetBufferSize(), NULL, &something );
    pPSBuf->Release();
    Thanks a lot!

    Regards,
    Robert Varga
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Code:
    test = D3DX11CompileFromFile( L"nameof.hlsl",NULL, NULL, "nameofproc", "cs_5_0", dwShaderFlags, NULL, NULL, &pPSBuf, NULL, NULL );
    This looks like Windows code. Literals like "nameofproc " are PCHAR. But literals like L"nameof.hls l" are PWCHAR.

    If your project is Unicode then "nameofproc " becomes PWCHAR which may cause a problem on the Unicode side.

    I suggest you a) use TCHAR or b) code Unicode explicitly.

    This is the TCHAR version:

    Code:
    test = D3DX11CompileFromFile( TEXT("nameof.hlsl"),NULL, NULL, TEXT("nameofproc"), TEXT("cs_5_0"), dwShaderFlags, NULL, NULL, &pPSBuf, NULL, NULL );

    Comment

    Working...