0
\$\begingroup\$

I've been reading about shaders and looking at code. I found this in the code I'm looking at and it obviously has "Basic.fxo" there.

BasicFX = new BasicEffect(device, L"FX/Basic.fxo");

Now my question is what the file is for? I look in the folder and there is Basic.fx, Basic.fxo, and Basic.cod. I'm familiar with Basic.fx that's the shader? So I took out the .fxo and .cod reran the program and it just regenerated the files? What are the .cod/.fxo files for? Where do they come from? What do they do?

\$\endgroup\$
  • \$\begingroup\$ What "code" are you looking at? \$\endgroup\$ – Philipp Jan 18 '15 at 5:25
  • \$\begingroup\$ @Philipp I'm looking at HLSL \$\endgroup\$ – Andrew Wilson Jan 18 '15 at 6:06
  • \$\begingroup\$ @AndrewWilson: whose HLSL? From where? How is anybody supposed to know what some arbitrary file named "Basic.fx" does? \$\endgroup\$ – Sean Middleditch Jan 18 '15 at 6:39
  • \$\begingroup\$ @SeanMiddleditch because the .fx, .fxo, and .cod file extensions are widely known. I asked about the file type not the files themselves. \$\endgroup\$ – Andrew Wilson Jan 18 '15 at 6:43
  • \$\begingroup\$ @AndrewWilson: ah, sorry, that's totally clear on second reading. \$\endgroup\$ – Sean Middleditch Jan 18 '15 at 7:43
2
\$\begingroup\$

The .fxo files are compiled shader files. Think of .obj/.o files for C and C++, but for HLSL. They're the result of running the shader compiler fxc.exe over your shader files.

The advantages of .fxo files are three fold. First, the make reverse engineering of your shader code a bit more difficult, which is advantageous for some of the higher-end games with a lot of secret sauce in their shaders.

Second, some platforms do not actually allow you to use the HLSL compiler. Earlier iterations of Windows Store apps for instance did not allow applications to use d3dcompiler_XX.dll, so it was mandatory to precompile shaders for these platforms. Even on plain ol' desktop Windows, you are responsible for shipping d3dcompiler_XX.dll as it is not part of the end-user redistribution package.

Third, compiling HLSL takes time. Precompiling the shaders shaves off some load time for an application, though it's not necessarily much time at all.

In general it's good practice to precompile your shaders and ship the .fxo files.

I've never seen a .cod file and don't know what it's for; Google is not clearing it up.

\$\endgroup\$
  • \$\begingroup\$ .cod stands for C/C++ Code Listing whatever that is. How would I debug an .fx file? \$\endgroup\$ – Andrew Wilson Jan 18 '15 at 8:20
  • \$\begingroup\$ Nevermind. It seems nVidia FX Composer would do it. Unless you recommend something else. Thanks. \$\endgroup\$ – Andrew Wilson Jan 18 '15 at 8:23
  • \$\begingroup\$ @AndrewWilson: there's a bunch of tools for it. Visual Studio's graphics debugger is my usual go to, but the individual hardware vendors also have their own tool suites for debugging shaders running on their hardware. \$\endgroup\$ – Sean Middleditch Jan 18 '15 at 21:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.