Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rts/Lua/LuaConstEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* @field noHandicapForReclaim boolean Whether handicap is applied to income from reclaim
* @field groupAddDoesntSelect boolean Whether 'group add' also selects the group (does both if false)
* @field deadTeamsKeepUnitLimit boolean Whether engine redistributes dead team unitlimit to allies (false) or keeps it as-is (true)
* @field reliableLuaMapShaders boolean Whether forward-only Lua map shaders activate without a deferred draw and Spring.SetMapShader program swaps refresh cached uniform locations
*/

/***
Expand Down Expand Up @@ -83,6 +84,7 @@ bool LuaConstEngine::PushEntries(lua_State* L)
LuaPushNamedBool(L, "noHandicapForReclaim", true);
LuaPushNamedBool(L, "groupAddDoesntSelect", true);
LuaPushNamedBool(L, "deadTeamsKeepUnitLimit", false);
LuaPushNamedBool(L, "reliableLuaMapShaders", true);
lua_rawset(L, -3);

lua_pushliteral(L, "textColorCodes");
Expand Down
6 changes: 6 additions & 0 deletions rts/Map/SMF/SMFRenderState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ void SMFRenderStateGLSL::Update(
for (uint32_t n = GLSL_SHADER_FWD_ADV; n <= GLSL_SHADER_DFR_ADV; n++) {
glslShaders[n]->LoadFromID(luaMapShaderData->shaderIDs[n - 1]);
}

// currShader is null from Init() (GLSL_SHADER_FWD_STD is never created for
// the Lua state), so re-evaluate it now that program IDs changed; otherwise
// HasValidShader(Normal) stays false and a forward-only Lua map shader is
// never selected until a deferred Lua draw happens to run first
SetCurrentShader(smfGroundDrawer, DrawPass::Normal);
} else {
assert(luaMapShaderData == nullptr);

Expand Down
4 changes: 4 additions & 0 deletions rts/Rendering/Shaders/Shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ namespace Shader {

// not needed for pre-compiled programs
shaderObjs.clear();
// cached locations/values belong to the previous program; without this,
// uniforms set by name (e.g. texSquare) target stale locations after a
// Spring.SetMapShader program swap
uniformStates.clear();
}

/// create the whole shader from a lua file
Expand Down
Loading