Fix shader reading yet again

This commit is contained in:
Jaime Passos 2020-01-27 02:15:34 -03:00
parent bdd43efb25
commit c87119f18f
3 changed files with 28 additions and 14 deletions

View File

@ -6147,13 +6147,14 @@ void HWR_AddSessionCommands(void)
// --------------------------------------------------------------------------
void HWR_Startup(void)
{
INT32 i;
static boolean startupdone = false;
// do this once
if (!startupdone)
{
INT32 i;
CONS_Printf("HWR_Startup()...\n");
HWR_InitPolyPool();
HWR_AddSessionCommands();
HWR_InitTextureCache();
@ -6161,16 +6162,17 @@ void HWR_Startup(void)
#ifdef ALAM_LIGHTING
HWR_InitLight();
#endif
// read every custom shader
for (i = 0; i < numwadfiles; i++)
HWR_ReadShaders(i, (wadfiles[i]->type == RET_PK3));
HWR_LoadShaders();
}
if (rendermode == render_opengl)
textureformat = patchformat = GR_RGBA;
startupdone = true;
for (i = 0; i < numwadfiles; i++)
HWR_LoadShaders(i, (wadfiles[i]->type == RET_PK3));
HWD.pfnInitCustomShaders();
}
// --------------------------------------------------------------------------
@ -6466,7 +6468,12 @@ static inline UINT16 HWR_CheckShader(UINT16 wadnum)
return INT16_MAX;
}
void HWR_LoadShaders(UINT16 wadnum, boolean PK3)
void HWR_LoadShaders(void)
{
HWD.pfnInitCustomShaders();
}
void HWR_ReadShaders(UINT16 wadnum, boolean PK3)
{
UINT16 lump;
char *shaderdef, *line;
@ -6497,9 +6504,6 @@ void HWR_LoadShaders(UINT16 wadnum, boolean PK3)
size = W_LumpLengthPwad(wadnum, lump);
line = Z_Malloc(size+1, PU_STATIC, NULL);
if (!line)
I_Error("HWR_LoadShaders: No more free memory\n");
M_Memcpy(line, shaderdef, size);
line[size] = '\0';
@ -6518,7 +6522,7 @@ void HWR_LoadShaders(UINT16 wadnum, boolean PK3)
value = strtok(NULL, "\r\n ");
if (!value)
{
CONS_Alert(CONS_WARNING, "HWR_LoadShaders: Missing shader type (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
CONS_Alert(CONS_WARNING, "HWR_ReadShaders: Missing shader type (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
stoken = strtok(NULL, "\r\n"); // skip end of line
goto skip_lump;
}
@ -6537,14 +6541,14 @@ skip_lump:
value = strtok(NULL, "\r\n= ");
if (!value)
{
CONS_Alert(CONS_WARNING, "HWR_LoadShaders: Missing shader target (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
CONS_Alert(CONS_WARNING, "HWR_ReadShaders: Missing shader target (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
stoken = strtok(NULL, "\r\n"); // skip end of line
goto skip_field;
}
if (!shadertype)
{
CONS_Alert(CONS_ERROR, "HWR_LoadShaders: Missing shader type (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
CONS_Alert(CONS_ERROR, "HWR_ReadShaders: Missing shader type (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
Z_Free(line);
return;
}
@ -6575,7 +6579,7 @@ skip_lump:
if (shader_lumpnum == INT16_MAX)
{
CONS_Alert(CONS_ERROR, "HWR_LoadShaders: Missing shader source %s (file %s, line %d)\n", shader_lumpname, wadfiles[wadnum]->filename, linenum);
CONS_Alert(CONS_ERROR, "HWR_ReadShaders: Missing shader source %s (file %s, line %d)\n", shader_lumpname, wadfiles[wadnum]->filename, linenum);
Z_Free(shader_lumpname);
continue;
}

View File

@ -69,7 +69,8 @@ void HWR_DrawScreenFinalTexture(int width, int height);
void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap);
UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap); // Let's see if this can work
void HWR_LoadShaders(UINT16 wadnum, boolean PK3);
void HWR_ReadShaders(UINT16 wadnum, boolean PK3);
void HWR_LoadShaders(void);
extern CV_PossibleValue_t granisotropicmode_cons_t[];

View File

@ -788,6 +788,15 @@ UINT16 W_InitFile(const char *filename, boolean mainfile)
wadfiles[numwadfiles] = wadfile;
numwadfiles++; // must come BEFORE W_LoadDehackedLumps, so any addfile called by COM_BufInsertText called by Lua doesn't overwrite what we just loaded
#ifdef HWRENDER
// Read shaders from file
if (rendermode == render_opengl && hwrenderloaded)
{
HWR_ReadShaders(numwadfiles - 1, (type == RET_PK3));
HWR_LoadShaders();
}
#endif // HWRENDER
// TODO: HACK ALERT - Load Lua & SOC stuff right here. I feel like this should be out of this place, but... Let's stick with this for now.
switch (wadfile->type)
{