R1 shader problem
by Dave · in Torque Game Engine Advanced · 02/17/2007 (5:05 am) · 22 replies
Hi folks,
Many of the shaders in the demo are not working, the terrain is black, the terrain is also black in the waterworld demo, and my own game just loads a bright yellow screen and hangs. I am getting the following errors in the log
shaders/legacyTerrain/terrainDynamicLightingMaskV.hlsl(2,10): error X1507: failed to open source file: '../shdrConsts.h'
GFXD3DShader::initVertShader - unable to compile shader!
error X3539: ps_1_x is not supported in this version of the compiler
The shdrConsts.h file is there. I don't know enough about shaders to understand the last line of the error messages. Is the compiler built into TGEA?
Appreciate any help, I searched for shdrConsts.h on the forums but found no similar errors or solutions.
This is happening for many shaders not just the one above. for example
shaders/lightingSystem/AlphaBloomShaderV.hlsl(7,10): error X1507: failed to open source file: '../shdrConsts.h'
GFXD3DShader::initVertShader - unable to compile shader!
shaders/lightingSystem/DownSample8x4ShaderV.hlsl(7,10): error X1507: failed to open source file: '../shdrConsts.h'
GFXD3DShader::initVertShader - unable to compile shader!
shaders/lightingSystem/DownSample8x4ShaderV.hlsl(7,10): error X1507: failed to open source file: '../shdrConsts.h'
GFXD3DShader::initVertShader - unable to compile shader!
shaders/lightingSystem/DownSample4x4BloomClampShaderV.hlsl(7,10): error X1507: failed to open source file: '../shdrConsts.h'
GFXD3DShader::initVertShader - unable to compile shader!
I don't get this problem with 4.2 even though it has an identical include for shdrConsts.h and dir structure. I'd guess there may be some working dir or path change set somewhere for the R1 shader compiler? Can't see why else it would happen. I didn't install in the default directory but that should make no difference right?
Thanks,
Dave.
Many of the shaders in the demo are not working, the terrain is black, the terrain is also black in the waterworld demo, and my own game just loads a bright yellow screen and hangs. I am getting the following errors in the log
shaders/legacyTerrain/terrainDynamicLightingMaskV.hlsl(2,10): error X1507: failed to open source file: '../shdrConsts.h'
GFXD3DShader::initVertShader - unable to compile shader!
error X3539: ps_1_x is not supported in this version of the compiler
The shdrConsts.h file is there. I don't know enough about shaders to understand the last line of the error messages. Is the compiler built into TGEA?
Appreciate any help, I searched for shdrConsts.h on the forums but found no similar errors or solutions.
shaders/lightingSystem/AlphaBloomShaderV.hlsl(7,10): error X1507: failed to open source file: '../shdrConsts.h'
GFXD3DShader::initVertShader - unable to compile shader!
shaders/lightingSystem/DownSample8x4ShaderV.hlsl(7,10): error X1507: failed to open source file: '../shdrConsts.h'
GFXD3DShader::initVertShader - unable to compile shader!
shaders/lightingSystem/DownSample8x4ShaderV.hlsl(7,10): error X1507: failed to open source file: '../shdrConsts.h'
GFXD3DShader::initVertShader - unable to compile shader!
shaders/lightingSystem/DownSample4x4BloomClampShaderV.hlsl(7,10): error X1507: failed to open source file: '../shdrConsts.h'
GFXD3DShader::initVertShader - unable to compile shader!
I don't get this problem with 4.2 even though it has an identical include for shdrConsts.h and dir structure. I'd guess there may be some working dir or path change set somewhere for the R1 shader compiler? Can't see why else it would happen. I didn't install in the default directory but that should make no difference right?
Thanks,
Dave.
About the author
#2
Do you know why this does not happen with 0.4.2 then? I am using the same DX SDK but the shader problems do not happen. I can't believe that release 1 uses older shaders than the EA 0.4.2!
BTW I reinstalled in the default dir and it made no difference.
Thanks,
Dave.
02/17/2007 (6:35 am)
Argh! OK, thanks Marc, if that is correct it is a real pain. Do you know why this does not happen with 0.4.2 then? I am using the same DX SDK but the shader problems do not happen. I can't believe that release 1 uses older shaders than the EA 0.4.2!
Thanks,
Dave.
#3
In gfxD3DShader.cpp on line 111 change:
And the same on line 195.
Works fine after that. I imagine Microsoft have a good reason for changing shader file pathing, but I don't think anyone has worked it out yet.
Enjoy.
-- Ricky
02/18/2007 (6:06 am)
There is a nice simple fix for this:In gfxD3DShader.cpp on line 111 change:
D3DXSHADER_DEBUG to D3DXSHADER_DEBUG | D3DXSHADER_USE_LEGACY_D3DX9_31_DLL
And the same on line 195.
Works fine after that. I imagine Microsoft have a good reason for changing shader file pathing, but I don't think anyone has worked it out yet.
Enjoy.
-- Ricky
#4
Thanks once more,
All the best,
Dave.
02/18/2007 (7:47 am)
Ricky, thanks a million. I found three refs but on different lines to the ones you gave me (I'm using release 1). I changed them all and it seems to have done the trick. The lines were 93, 177 and 214.Thanks once more,
All the best,
Dave.
#5
However, there can be some improvement - from what I understand, the suggested code changes just revert back to the old dll and won't take advantage of improvements the new one may have :(.
However - that can be easily changed :). I've implemented some code that tries the new dll first, then if that fails, falls back to the old dll - allowing you to take advantage of any improvements to the new dll without sacrificing compatibility!
NOTE: All of my changes are to gfxD3DShader.cpp, and are additions to, not replacements of, the existing code.
ADD AFTER line 93:
ADD AFTER line 184:
ADD AFTER line 229:
03/24/2007 (8:52 pm)
Thanks a lot for the info!However, there can be some improvement - from what I understand, the suggested code changes just revert back to the old dll and won't take advantage of improvements the new one may have :(.
However - that can be easily changed :). I've implemented some code that tries the new dll first, then if that fails, falls back to the old dll - allowing you to take advantage of any improvements to the new dll without sacrificing compatibility!
NOTE: All of my changes are to gfxD3DShader.cpp, and are additions to, not replacements of, the existing code.
ADD AFTER line 93:
if( res != D3D_OK )
{
// Fall back to old dll containing shader 1.x if newer dll fails
res = GFXD3DX.D3DXCompileShaderFromFileA( vertFile, NULL, NULL, "main",
vertTarget, D3DXSHADER_DEBUG | D3DXSHADER_USE_LEGACY_D3DX9_31_DLL, &code, &errorBuff, NULL );
}ADD AFTER line 184:
if( res != D3D_OK )
{
// Fall back to old dll containing shader 1.x if newer dll fails
res = GFXD3DX.D3DXCompileShaderFromFileA( pixFile, NULL, NULL, "main", pixTarget,
D3DXSHADER_DEBUG | D3DXSHADER_USE_LEGACY_D3DX9_31_DLL, &code, &errorBuff, NULL );
}ADD AFTER line 229:
if( res != D3D_OK )
{
// Fall back to old dll containing shader 1.x if newer dll fails
res = GFXD3DX.D3DXAssembleShaderFromFileA( pixFile, 0, NULL, D3DXSHADER_DEBUG | D3DXSHADER_USE_LEGACY_D3DX9_31_DLL, &code, &errorBuff );
}
#6
-DD3DXSHADER_USE_LEGACY_D3DX9_31_DLL=true
to the command line compile options in the solution ?
04/12/2007 (9:22 am)
Can't you just add-DD3DXSHADER_USE_LEGACY_D3DX9_31_DLL=true
to the command line compile options in the solution ?
#7
-Gavin
04/12/2007 (11:05 am)
@Jerimiah - Thanks for the fix!! I just applied the three changes mentioned above and can now compile in debug mode with no shader errors, and I didn't have to revert to an older version of the directX SDK (I'm using Feb07). -Gavin
#8
Frank: Your solution is compile time, and forces all shaders to revert to the old dll and will not use the new one. My solution is run time, and falls back to the old dll only if necessary and will be able to take advantage of the new dll for shaders that use it.
The lines where I added the code to in TGEA 1.0.3:
100, 143, 200, 242
11/07/2007 (8:19 am)
Since the bug hasn't been fixed three revisions later, and since no more fixes are coming now that they're working on another rewrite of Torque (again) which may take a couple years to complete, here's a friendly reminder that there's still a fix for this problem.Frank: Your solution is compile time, and forces all shaders to revert to the old dll and will not use the new one. My solution is run time, and falls back to the old dll only if necessary and will be able to take advantage of the new dll for shaders that use it.
The lines where I added the code to in TGEA 1.0.3:
100, 143, 200, 242
#9
You release a game with 1 specific DX DLL not with 2+.
And one specific actually means:
1. You either use DX pre Dec 2006 and have 1.1 support
2. You use DX Dec 2006 and later, where 1.1 isn't supported anymore which means that you use 2.0 as min requirement and just redefine the shaders to be 2.0
3. You use above one and use legacy support for not supported 1.1 and have both.
11/07/2007 (8:45 am)
Your solution is as well a hack.You release a game with 1 specific DX DLL not with 2+.
And one specific actually means:
1. You either use DX pre Dec 2006 and have 1.1 support
2. You use DX Dec 2006 and later, where 1.1 isn't supported anymore which means that you use 2.0 as min requirement and just redefine the shaders to be 2.0
3. You use above one and use legacy support for not supported 1.1 and have both.
#10
It's not a DLL distributed with a game, it's a DLL distributed with the OS. The DLL is part of DirectX, and I have to deal with whatever DLL they give their users.
This is a run time error, not a compile time error.
Who are you to determine what I want for the minimum requirements for my game?
I'm not quite sure what you're trying to say here.
. . . and I'm still having problems with 1.0.3 of TGEA, may have to look at it more closely.
11/07/2007 (9:11 am)
Quote:You release a game with 1 specific DX DLL not with 2+.
It's not a DLL distributed with a game, it's a DLL distributed with the OS. The DLL is part of DirectX, and I have to deal with whatever DLL they give their users.
This is a run time error, not a compile time error.
Quote:You use DX Dec 2006 and later, where 1.1 isn't supported anymore which means that you use 2.0 as min requirement and just redefine the shaders to be 2.0
Who are you to determine what I want for the minimum requirements for my game?
Quote:You use above one and use legacy support for not supported 1.1 and have both.
I'm not quite sure what you're trying to say here.
. . . and I'm still having problems with 1.0.3 of TGEA, may have to look at it more closely.
#11
I just repeated the minimum requirements of DX of Dec 2006 and newer, where Shader 2.0 is the minimum required shader supported in non legacy mode. As well as Windows 2K / XP.
If you want to use a DX Version starting with Dec 2006 and later, you can either use legacy , which reenables 1.1 support by compiling it with the old compiler (the new one is SM2 +) or you can switch to an older DX version and change TGEA accordingly to use it (as TGEA was updated to Feb 2007 and got the legacy switch added to work with it correctly). Or you can respecify your shaders as Shader Model 2 shaders (and potentially optimize them or in case of the terrain shader just kick them as 2.0 versions already exist)
And you distribute a DX Runtime installer with your game normally. But you are right that it will distribute all versions up to the one existant at that point. But that doesn't change the fact that you write your game normally for 1 specific DX version unlike you want to do double consistency checks as changes in the shader compiler etc between the versions can lead to different result (visual but especially performance wise)
11/07/2007 (9:46 am)
I don't determine your minimum requirements. You are doing it!I just repeated the minimum requirements of DX of Dec 2006 and newer, where Shader 2.0 is the minimum required shader supported in non legacy mode. As well as Windows 2K / XP.
If you want to use a DX Version starting with Dec 2006 and later, you can either use legacy , which reenables 1.1 support by compiling it with the old compiler (the new one is SM2 +) or you can switch to an older DX version and change TGEA accordingly to use it (as TGEA was updated to Feb 2007 and got the legacy switch added to work with it correctly). Or you can respecify your shaders as Shader Model 2 shaders (and potentially optimize them or in case of the terrain shader just kick them as 2.0 versions already exist)
And you distribute a DX Runtime installer with your game normally. But you are right that it will distribute all versions up to the one existant at that point. But that doesn't change the fact that you write your game normally for 1 specific DX version unlike you want to do double consistency checks as changes in the shader compiler etc between the versions can lead to different result (visual but especially performance wise)
#12
Or I can do what I've done here and only enable legacy when it's needed.
I'm too lazy ^_^. Besides, I'm still learning them, and most of them I've borrowed from TGEA itself. I've yet to create my own shaders.
Why? Virtually everybody has at least DirectX 9.0c by now, and if Microsoft releases further updates, I'm sure they'll be sent to everybody via Windows Update. Including DirectX in a game is redundant and not necessary anymore. If they for some reason they really don't have it, I'd just pop up a dialog saying it's required and have a link to Microsoft's DirectX website.
There's not a game developer in the world that ignores backwards compatibility. Half-Life 2 runs on DirectX 9, 8, and 7. HL2: Episode 2 runs on DirectX 9 and 8. Bioshock runs on DirectX 10 and 9. Nearly every new game is going to run on at least DirectX 10 for high-end Vista machines and DirectX 9 for compatibility with XP. Contrary to your claims, nobody develops for a single version of DirectX.
Maybe someday I'll learn HLSL and create my own shaders so they can all be at least level 2. Right now, however, I'm pretty much stuck with what I've got. I'd rather spend time creating the game than learning a shading language.
11/07/2007 (2:37 pm)
Quote:If you want to use a DX Version starting with Dec 2006 and later, you can either use legacy , which reenables 1.1 support by compiling it with the old compiler (the new one is SM2 +) or you can switch to an older DX version and change TGEA accordingly to use it
Or I can do what I've done here and only enable legacy when it's needed.
Quote:Or you can respecify your shaders as Shader Model 2 shaders
I'm too lazy ^_^. Besides, I'm still learning them, and most of them I've borrowed from TGEA itself. I've yet to create my own shaders.
Quote:
And you distribute a DX Runtime installer with your game normally.
Why? Virtually everybody has at least DirectX 9.0c by now, and if Microsoft releases further updates, I'm sure they'll be sent to everybody via Windows Update. Including DirectX in a game is redundant and not necessary anymore. If they for some reason they really don't have it, I'd just pop up a dialog saying it's required and have a link to Microsoft's DirectX website.
Quote:But that doesn't change the fact that you write your game normally for 1 specific DX version
There's not a game developer in the world that ignores backwards compatibility. Half-Life 2 runs on DirectX 9, 8, and 7. HL2: Episode 2 runs on DirectX 9 and 8. Bioshock runs on DirectX 10 and 9. Nearly every new game is going to run on at least DirectX 10 for high-end Vista machines and DirectX 9 for compatibility with XP. Contrary to your claims, nobody develops for a single version of DirectX.
Maybe someday I'll learn HLSL and create my own shaders so they can all be at least level 2. Right now, however, I'm pretty much stuck with what I've got. I'd rather spend time creating the game than learning a shading language.
#13
1. DX is NOT updated through windows update
2. There are 14+ versions of DX9.0c by now (there is a new one every 2 months +-). So the chance that the users are not on the needed version for your game is there.
Its common practice to do the DX install during install of the game, normally even silently as it does not do anything else than add those runtime library versions that are not already present. So a fully up to date user sees no difference, an outdated machine although would get the needed runtime to have your game running.
With single version I mean targeted at a single version of the DX Major version decided. Nobody develops for DX 9.0c Oct 2007 and for DX 9.0c Sept 2006 and DX 9.0c Dec 2005 in the same app, this would lead to major flaws and incosistencies (run TGEA without having the proper DX 9.0c installed and experience the purple errors yourself in case you do not believe that).
Doing it for different major versions is something completely different as this are totally distinct renderer implementations as different DX major versions can not communicate with each other or interfer each other. (especially DX7 -> DX8,9 and DX9 -> DX10)
11/07/2007 (5:20 pm)
That missassumption about DX is the reason that for most new TGEA users it bombs out or shows funny purple effects:1. DX is NOT updated through windows update
2. There are 14+ versions of DX9.0c by now (there is a new one every 2 months +-). So the chance that the users are not on the needed version for your game is there.
Its common practice to do the DX install during install of the game, normally even silently as it does not do anything else than add those runtime library versions that are not already present. So a fully up to date user sees no difference, an outdated machine although would get the needed runtime to have your game running.
With single version I mean targeted at a single version of the DX Major version decided. Nobody develops for DX 9.0c Oct 2007 and for DX 9.0c Sept 2006 and DX 9.0c Dec 2005 in the same app, this would lead to major flaws and incosistencies (run TGEA without having the proper DX 9.0c installed and experience the purple errors yourself in case you do not believe that).
Doing it for different major versions is something completely different as this are totally distinct renderer implementations as different DX major versions can not communicate with each other or interfer each other. (especially DX7 -> DX8,9 and DX9 -> DX10)
#14
Dave.
11/08/2007 (12:51 am)
Your argument is very interesting as it's teaching me a bit more about DX implementations. But please calm down a bit :-)Dave.
#15
And yeah, I'll try to learn HLSL to update my shaders.
11/08/2007 (7:53 am)
Okay - including (or at least detecting) DirectX does make a bit of sense - but I'm on DirectX 10 due to Vista, and I don't know how to include both DirectX 9 and 10 with my game. Where do I get the latest version of both of the run times to include in an installer?And yeah, I'll try to learn HLSL to update my shaders.
#16
The DX9 runtime installer comes with the SDK or can be downloaded from the microsoft page
On vista, this is especially needed as vista only comes with a single version of DX9.0c, which is the Feb 2007 version. all other version (previous to that one, as well as the April, June, ... 2007) are not existant
11/08/2007 (11:48 pm)
You don't need to include a DX10 install in your game. TGEA is DX9.0c and does not use nor support DX10The DX9 runtime installer comes with the SDK or can be downloaded from the microsoft page
On vista, this is especially needed as vista only comes with a single version of DX9.0c, which is the Feb 2007 version. all other version (previous to that one, as well as the April, June, ... 2007) are not existant
#17
Thanks,
Dave.
11/12/2007 (3:33 am)
Hey, where did that info about another rewrite of TGEA come from? I'd like to see what the plans are if you could point me in the right direction please.Thanks,
Dave.
#18
11/12/2007 (3:57 pm)
What rewrite or to what are you exactly referring?
#19
11/13/2007 (2:00 am)
Hi, The one Jeremiah mentioned in a post above on Nov 7th at 16:19 GMT
#20
11/13/2007 (3:17 am)
Ah. That is referring to the news that GG is working on Torque 2 which was mentioned to be meant to replace all current Torque engines at some point in the future.
Torque 3D Owner Marc Dreamora Schaerer
Gayasoft
You need to use Oct 06 DX SDK, not Dec 06 or Feb 07. After Oct 06, Shader 2.0 was the base shader, no shader versions below which will fail with shaders of a lower version which is the case for many default shaders.
MS dropped support for Shader 1 and Win98 / ME at that point.