Skip to content

Commit

Permalink
Vulkan: Retain original styles in stylesPreserved during shader initi…
Browse files Browse the repository at this point in the history
…alization
  • Loading branch information
JKSunny committed Oct 14, 2024
1 parent 46e81c9 commit 7a69fe6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions codemp/rd-vulkan/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,9 @@ typedef struct shader_s {
int lightmapSearchIndex[MAXLIGHTMAPS]; // for a shader to match, both name and lightmapIndex must match
int lightmapIndex[MAXLIGHTMAPS]; // for a shader to match, both name and lightmapIndex must match
byte styles[MAXLIGHTMAPS];
#ifdef USE_VK_IMGUI
byte stylesPreserved[MAXLIGHTMAPS]; // use original state for updatedShader
#endif

int index; // this shader == tr.shaders[index]
int sortedIndex; // this shader == tr.sortedShaders[sortedIndex]
Expand Down
8 changes: 7 additions & 1 deletion codemp/rd-vulkan/tr_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3436,6 +3436,12 @@ static void InitShader( const char *name, const int *lightmapIndex, const byte *
// because shader search functions expects this
// otherwise they will fail and cause massive duplication
Com_Memcpy(shader.lightmapSearchIndex, shader.lightmapIndex, sizeof(shader.lightmapSearchIndex));
#ifdef USE_VK_IMGUI
// preserve for updatedShader
Com_Memcpy(shader.stylesPreserved, shader.styles, sizeof(shader.stylesPreserved));
#endif



for (i = 0; i < MAX_SHADER_STAGES; i++) {
stages[i].bundle[0].texMods = texMods[i];
Expand Down Expand Up @@ -3544,7 +3550,7 @@ void R_UpdateShader( int index, const char *shaderText, qboolean bulk ) {
}

// clear the global shader
InitShader( name, sh->lightmapSearchIndex, sh->styles );
InitShader( name, sh->lightmapSearchIndex, sh->stylesPreserved );

if ( !ParseShader( &shaderTextPtr ) )
setDefaultShader(); // had errors, so use default shader
Expand Down

0 comments on commit 7a69fe6

Please sign in to comment.