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\$
5
  • \$\begingroup\$ What "code" are you looking at? \$\endgroup\$ Commented Jan 18, 2015 at 5:25
  • \$\begingroup\$ @Philipp I'm looking at HLSL \$\endgroup\$ Commented Jan 18, 2015 at 6:06
  • \$\begingroup\$ @AndrewWilson: whose HLSL? From where? How is anybody supposed to know what some arbitrary file named "Basic.fx" does? \$\endgroup\$ Commented Jan 18, 2015 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\$ Commented Jan 18, 2015 at 6:43
  • \$\begingroup\$ @AndrewWilson: ah, sorry, that's totally clear on second reading. \$\endgroup\$ Commented Jan 18, 2015 at 7:43

1 Answer 1

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\$
3
  • \$\begingroup\$ .cod stands for C/C++ Code Listing whatever that is. How would I debug an .fx file? \$\endgroup\$ Commented Jan 18, 2015 at 8:20
  • \$\begingroup\$ Nevermind. It seems nVidia FX Composer would do it. Unless you recommend something else. Thanks. \$\endgroup\$ Commented Jan 18, 2015 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\$ Commented Jan 18, 2015 at 21:48

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.