Quake3World.com Forums
     Programming Discussion
        out of range hShader


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: out of range hShader

Warrior
Warrior
Joined: 16 Jun 2005
Posts: 76
PostPosted: 10-28-2005 01:08 PM           Profile Send private message  E-mail  Edit post Reply with quote


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?



_________________
Smokin' Guns
Monster Browser


Top
                 

Warrior
Warrior
Joined: 24 Jul 2005
Posts: 93
PostPosted: 10-28-2005 10:14 PM           Profile Send private message  E-mail  Edit post Reply with quote


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

R_GetShaderByHandle: (tr_shader.c)

Code:
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];
}




Top
                 

Warrior
Warrior
Joined: 16 Jun 2005
Posts: 76
PostPosted: 10-29-2005 02:32 AM           Profile Send private message  E-mail  Edit post Reply with quote


I've seen that, but it doesn't help me much...



_________________
Smokin' Guns
Monster Browser


Top
                 

Mentor
Mentor
Joined: 12 Mar 2005
Posts: 3958
PostPosted: 10-29-2005 04:46 AM           Profile Send private message  E-mail  Edit post Reply with quote


Does your mod remap shaders?




Top
                 

Warrior
Warrior
Joined: 24 Jul 2005
Posts: 93
PostPosted: 10-29-2005 01:30 PM           Profile Send private message  E-mail  Edit post Reply with quote


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)




Top
                 

Warrior
Warrior
Joined: 16 Jun 2005
Posts: 76
PostPosted: 10-29-2005 03:02 PM           Profile Send private message  E-mail  Edit post Reply with quote


^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:
@@ -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?



_________________
Smokin' Guns
Monster Browser


Top
                 

Warrior
Warrior
Joined: 24 Jul 2005
Posts: 93
PostPosted: 10-29-2005 07:47 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

Mentor
Mentor
Joined: 12 Mar 2005
Posts: 3958
PostPosted: 10-30-2005 06:08 AM           Profile Send private message  E-mail  Edit post Reply with quote


torhu wrote:
Does that help?

I should hope so. Does the problem persist?




Top
                 

Warrior
Warrior
Joined: 16 Jun 2005
Posts: 76
PostPosted: 10-30-2005 03:53 PM           Profile Send private message  E-mail  Edit post Reply with quote


^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:



_________________
Smokin' Guns
Monster Browser


Top
                 

Mentor
Mentor
Joined: 12 Mar 2005
Posts: 3958
PostPosted: 10-31-2005 03:30 AM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 
Quake3World.com | Forum Index | Programming Discussion


Post new topic Reply to topic


cron
Quake3World.com
© ZeniMax. Zenimax, QUAKE III ARENA, Id Software and associated trademarks are trademarks of the ZeniMax group of companies. All rights reserved.
This is an unofficial fan website without any affiliation with or endorsement by ZeniMax.
All views and opinions expressed are those of the author.