1
\$\begingroup\$

General confusion... I'm not using Effects11 yet.

Regarding the sorting/grouping induced by filenames:

Initially I had them grouped by shader type:
SomePurpose1.hlsli
SomePurpose1_SubPurpose1.hlsli
VS_SomePurpose1.hlsl
VS_SomePurpose1_SubPurpose1.hlsl
GS_GenericPurpose1.hlsl
GS_SomePurpose1.hlsl
PS_SomePurpose1.hlsl
PS_SomePurpose1_SubPurpose1.hlsl

Different parts of one "effect" were separated, so I reorganized:
GS_GenericPurpose1.hlsl
SomePurpose1_VS.hlsl
SomePurpose1_GS.hlsl
SomePurpose1_PS.hlsl
SomePurpose1_SubPurpose1_VS.hlsl
SomePurpose1_SubPurpose1_PS.hlsl

Regarding whether I need, "need", or even want to use Effects11:

I'm going to have 100's of shader blob files by the end of it; is this the "line in the sand" that defines moving to "effects", rather than using the individual blobs?

It would be 1000X better as:
GS_GenericPurpose1.hlsl
SomePurpose1.fxi
SomePurpose1.fx
SomePurpose1_SubPurpose1.fx

I'm familiar with XNA Effects and I've, now, mastered manually juggling the blobs, states and buffers in C++ without Effects11. To cure the number-of-files bloating and to make it easier to manage, overall, I think I "need" to use Effects11. XNA let me produce results without understanding, or even knowing, what I was actually doing. Now that I know better, I want to make sure my basics are solid.

I'm using the DX ToolKit helpers which defines some common states:
Where applying DepthDefault fully configures the depth-stencil-state, I conceptualize Effects, in general, doing the same job, except that they fully configure the "shader-state", i.e. applying all of the individual shaders, shader resources, etc, etc, etc, all as a one-shot call to Apply().

  1. Is that an accurate summation? If so, using Effects is just going to allow me to collect all of the individual state calls into fewer Effect calls.
  2. The same amount of calls need to be made, regardless of how they're initiated, so I'm assuming an "Effect" doesn't really incur any performance penalties. Is there an increase/decrease in overhead using Effects11?
  3. Are there any subtle or hidden benefits/caveats?
\$\endgroup\$
  • \$\begingroup\$ You really should have lead with the questions. I had to scroll down the entire giant chunk of text in order to tell what you are even asking. \$\endgroup\$ – jhocking May 6 '15 at 13:05
3
\$\begingroup\$

First, Effects 11 is deprecated, or rather the HLSL profile you need to use it (fx_5_0) is deprecated. You can use still it with the Windows 8.x SDK copy of D3DCompile, particularly if you are using the GitHub open source version of the FX11 library as long as you are comfortable with this caveat. You don't 'need' to use it, but some people have found it useful and there are many older books that make use of it.

The main value in the Effects library (FX9, FX10, FX11) is allowing you describe in the .fx file the combination of shader programs you want to use in a grouping (aka technique) along with some associated state. Without Effects, you just need to coordinate between your HLSL shaders, your content, and your C/C++ code that does the rendering.

The problem is that the FX solution doesn't really scale well, and it's generally better in large games and applications to have your own bespoke material and state management anyhow.

If you are using DirectX Tool Kit, you can get a long way just using the existing 'canned' shaders in BasicEffect et al, perhaps adding some custom pixel shader or vertex shader where the stock stuff doesn't do what you want. It's certainly enough to get you going while you learn all the other aspects of Direct3D 11 programming as well. See the DirectX Tool Kit tutorial Writing custom shaders.

You could also try using the built-in VS DGSL shader visual editor which DirectX Tool Kit supports with DGSLEffect. It's kind of 'toy' as well, but you can experiment with it and use it to learn HLSL by example. See DirectX Tool Kit tutorial Creating custom shaders with DGSL

\$\endgroup\$
  • \$\begingroup\$ Note that I linked to the CodePlex site for the tutorial content. I'm in the midst of moving all the content from CodePlex to GitHub, so expect it to be available there as well in the next week or so... \$\endgroup\$ – Chuck Walbourn Jun 23 '15 at 7:43

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.