rjhwinner03
rjhwinner03

Reputation: 19

Directx 12 says that it cannot find the path specified when I run a demo project from a book

I am trying to learn directx 12 by reading Frank Luna's Introduction to Directx 12 book. I have all of the requirements(at least I think I do anyway), but I still get an error when I try to run the demo project(It came with a source code cd but I don't have a cd drive in my computer, so i had to find the GitHub version instead; but i don't know if it is right or not). When I did this it says hr failed in \mac\home\esktop\d3d12book-master\common\d3dutil.cpp;line 111;error:The system cannot find the path specified(It says "mac" because i am using a virtual machine).

Here are the book's requirements Windows 10(which i am running in the virtual machine) Visual Studio 2015 or Later A driver that supports directx12

Here is a link to the source code that i downloaded and a link to a pdf file for this book.

GitHub source File:https://github.com/d3dcoder/d3d12book

Also I am using visual studio 2015 community it that really makes a difference

Upvotes: 1

Views: 1741

Answers (5)

Feng
Feng

Reputation: 29

copy shader folder containing the hlsl file to where the exe resides

Upvotes: 0

YangZai
YangZai

Reputation: 323

I learn Dx12 with the same book and code sample. I guess that what actually caused this problem is the function callings in BoxApp.cpp at line 354 or 355:

    mvsByteCode = d3dUtil::CompileShader(L"Shaders\\color.hlsl", nullptr, "VS", "vs_5_0");
    mpsByteCode = d3dUtil::CompileShader(L"Shaders\\color.hlsl", nullptr, "PS", "ps_5_0");

Because d3dUtil::CompileShader is defined in d3dUtil.cpp at line 90-113, so the callings will be resolved to d3dUtil.cpp, and this is where the exception being thrown.

Look the first argument passed to CompileShader, it indicates that the shader source code can be found in a folder called "Shaders" in the current directory of your program. So copying "Shaders" into the directory meets the semantics here.

Generally, when your program reads a file, you should use file path to tell your program where the file resides. And you can use either absolute path or relative path. The code here uses relative path.

Upvotes: 1

Ward
Ward

Reputation: 11

It was hard to understand what to do to fix this problem. You simply have to make sure the .exe from the build is in the same place as the shader folder and it should work just fine. At least it did for me. What I did to run this example was simply copy the .exe from the build to the box folder which has the shader folder and the program ran just fine.

Upvotes: 1

GabeV
GabeV

Reputation: 1056

I got this same problem. I worked around it by opening the existing Box.sln VS solution instead of creating my own like the book instructs. I found it in the Box folder right alongside the Shaders folder. This one builds and runs just fine.

I opened an issue in the GitHub repo but it's been a while since there was activity there, so I doubt it'll get addressed.

Upvotes: 1

Gor Davtyan
Gor Davtyan

Reputation: 31

I've got the same problem.

The solution is to copy the "Shaders" folder from:

'C:\...\d3d12book-master\Chapter 6 Drawing

in Direct3D\Box'

to

'C:\...\d3d12book-master\MyCode\Box\Box'

enter image description here

Upvotes: 3

Related Questions