out of range hShader

Locked
torhu
Posts: 76
Joined: Thu Jun 16, 2005 7:57 pm

out of range hShader

Post by torhu »

In the latest test version of our mod, I occasionally get this message in the console:

"R_GetShaderByHandle: out of range hShader '1970169165' "

But I can't see any graphics anomalies, and there are no other problems reported in the console. Or maybe I saw something weird the first time, which made me open the console and look, can't quite remember now. The messages always seems to show up maybe 4 to 10 times in a row, with the same number. The number is different each session.

I haven't noticed this message in the earlier test versions. That's odd, because there are no shader-related changes. And the map I saw it first on was an old one.

I read something about this error that led me to the icculus.org svn repository. What I read there suggested that it might just be a bug in the engine. But it's a peculiar that I haven't seen in the older version of our mod. Should I just ignore this? Is it just random, or can it be fixed in a mod?
[url=http://www.smokin-guns.org]Smokin' Guns[/url]
[url=https://sites.google.com/site/monsterbrowser//]Monster Browser[/url]
ensiform
Posts: 93
Joined: Mon Jul 25, 2005 5:20 am

Post by ensiform »

well i see two places where this message is occuring,,,

R_GetShaderByHandle: (tr_shader.c)

Code: Select all

shader_t *R_GetShaderByHandle( qhandle_t hShader ) {
	if ( hShader < 0 ) {
	  ri.Printf( PRINT_WARNING, "R_GetShaderByHandle: out of range hShader '%d'\n", hShader ); // bk: FIXME name
		return tr.defaultShader;
	}
	if ( hShader >= tr.numShaders ) {
		ri.Printf( PRINT_WARNING, "R_GetShaderByHandle: out of range hShader '%d'\n", hShader );
		return tr.defaultShader;
	}
	return tr.shaders[hShader];
}
torhu
Posts: 76
Joined: Thu Jun 16, 2005 7:57 pm

Post by torhu »

I've seen that, but it doesn't help me much...
[url=http://www.smokin-guns.org]Smokin' Guns[/url]
[url=https://sites.google.com/site/monsterbrowser//]Monster Browser[/url]
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

Does your mod remap shaders?
ensiform
Posts: 93
Joined: Mon Jul 25, 2005 5:20 am

Post by ensiform »

torhu wrote:I've seen that, but it doesn't help me much...
basically something is calling R_GetShaderByHandle and the shader is null or greater-than/equal to tr.numShaders

its called in the following files:
  • tr_animation.c
    tr_cmds.c
    tr_main.c (2x)
    tr_mesh.c
    tr_scene.c
    tr_shader.c (2x)
torhu
Posts: 76
Joined: Thu Jun 16, 2005 7:57 pm

Post by torhu »

^misantropia^ wrote:Does your mod remap shaders?
I don't quite know how the shader stuff works yet. But I tried playing the map where I got the error message, with a breakpoint set on trap_R_RemapShader, and it was never called. But I didn't get the error either.

There are no remapShader commands issued from anywhere in the mod code. I don't know if a remap can be triggered by the map itself.

I've fixed the dubious call to trap_R_RemapShader in cg.servercmds.c, by just copying the code from UI_ConsoleCommand:

Code: Select all

@@ -1036,7 +1036,11 @@ static void CG_ServerCommand( void ) {
 
   if ( Q_stricmp (cmd, "remapShader") == 0 ) {
 		if (trap_Argc() == 4) {
-			trap_R_RemapShader(CG_Argv(1), CG_Argv(2), CG_Argv(3));
+			char shader1[MAX_QPATH];
+			char shader2[MAX_QPATH];
+			Q_strncpyz(shader1, CG_Argv(1), sizeof(shader1));
+			Q_strncpyz(shader2, CG_Argv(2), sizeof(shader2));
+			trap_R_RemapShader(shader1, shader2, CG_Argv(3));
 		}
 	}
 
And BuildShaderStateConfig in g_utils.c is commented out, so CS_SHADERSTATE probably won't be changed either. Which again should mean that CG_ShaderStateChanged doesn't call trap_R_RemapShader.

Does that help?
[url=http://www.smokin-guns.org]Smokin' Guns[/url]
[url=https://sites.google.com/site/monsterbrowser//]Monster Browser[/url]
ensiform
Posts: 93
Joined: Mon Jul 25, 2005 5:20 am

Post by ensiform »

yes a remap can be done in a map itself,,,

key: _remap01
value: old;new

at least u can do that for models i know, most likely for worldspawn too.
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

torhu wrote:Does that help?
I should hope so. Does the problem persist?
torhu
Posts: 76
Joined: Thu Jun 16, 2005 7:57 pm

Post by torhu »

^misantropia^ wrote:
torhu wrote:Does that help?
I should hope so. Does the problem persist?
Sorry if I was unclear. I meant to ask if it helps you to help me, not if it helps with the bug. Because that fix is in the code of the version I'm getting the error message with. So it doesn't seem to matter. :icon26:
[url=http://www.smokin-guns.org]Smokin' Guns[/url]
[url=https://sites.google.com/site/monsterbrowser//]Monster Browser[/url]
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Post by ^misantropia^ »

Build a debug version from the icculus.org SVN repository, run it with a breakpoint set on R_GetShaderByHandle (or even better, at the ri.Printf() lines) and do a backtrace. That should tell you where the error originates from - if it doesn't, post the backtrace here. Set in_nograb to 1 if you're using Linux.
Locked