Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17560

Pixel shader compiling issue - Windows 10 specific !?

$
0
0

Hi all

I'm facing some weird problems with some game's HLSL shaders, on Windows 10 exclusively.

The shaders are compiled against DX 11 / shader model 5. In case it matters, they still use the old fashioned DX9 methods tex2D etc. for sampling because they initially had been written for DX9 / shader model 3 and later been migrated with least possible effort.

There are different variations of pixel shaders that the game engine applies depending on in-game weather (ie. one pixel shader for dry weather, a different one for rain etc.). As those variations share large parts of the same code, those code parts are being referenced as #include directives, and the differences have been implemented as #define and #undef directives (e.g. rain shader defines a part for rendering the ground as wet, dry shader does not).

The game engine compiles all source shader files upon start-up, one by one, in a predefined (hard-coded) order, using the usual D3D commands.

NOW:

  • On my Vista 64bit environment, the D3D compiler seems to figure out which included shader source files are being used anywhere (ie. in at least one of the pixel shader variants), and compiles all used includes.
     
  • On my Windows 10 64bit environment, things behave differently: If the compiler encounters some include not being used in the first compiled shader file, it DOES NOT COMPILE that include file REGARDLESS it being used in subsequent file to compile !!!

Pseudo code sample:

// Pixel shader for dry weather (= first file being compiled)

#include "SomeSettingsFile.h"

#include "GenericShaderForAllWeatherTypes.h"
// Pixel shader for rainy weather (= second file being compiled)

#include "SomeSettingsFile.h"

#define IT_RAINS

#include "GenericShaderForAllWeatherTypes.h"
// GenericShaderForAllWeatherTypes.h

[...]

#ifdef IT_RAINS

#include "RainShader.h"
render_things_as_wet();

#endif

[...]

On Vista this works as expected: Source file "RainShader.h" is always being compiled an thus available on runtime.

On Windows 10 is does not: "RainShader.h" and the code segment starting with #ifdef IT_RAINS will be omitted / "optimized away" by the compiler because the first shader being compiled does not use it!!!

Any ideas???


Viewing all articles
Browse latest Browse all 17560

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>