From 931ffea17bec32e6f2ec8406cba9d48091d2d73e Mon Sep 17 00:00:00 2001 From: bjorn Date: Sat, 10 Sep 2022 10:28:54 -0700 Subject: [PATCH] Pass:getClear returns correct value for dontcare/load actions; --- src/api/l_graphics_pass.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/api/l_graphics_pass.c b/src/api/l_graphics_pass.c index 8e74fccc..3f8d6cfb 100644 --- a/src/api/l_graphics_pass.c +++ b/src/api/l_graphics_pass.c @@ -76,6 +76,7 @@ static int l_lovrPassGetTarget(lua_State* L) { static int l_lovrPassGetClear(lua_State* L) { Pass* pass = luax_checktype(L, 1, Pass); + const PassInfo* info = lovrPassGetInfo(pass); uint32_t count = 0; float color[4][4]; @@ -86,16 +87,19 @@ static int l_lovrPassGetClear(lua_State* L) { lua_createtable(L, (int) count, 2); for (int i = 0; i < (int) count; i++) { - lua_createtable(L, 4, 0); - for (int j = 0; j < 4; j++) { - lua_pushnumber(L, color[i][j]); - lua_rawseti(L, -2, j + 1); + if (info->canvas.loads[i] == LOAD_CLEAR) { + lua_createtable(L, 4, 0); + for (int j = 0; j < 4; j++) { + lua_pushnumber(L, color[i][j]); + lua_rawseti(L, -2, j + 1); + } + } else { + lua_pushboolean(L, info->canvas.loads[i] == LOAD_DISCARD); } + lua_rawseti(L, -2, i + 1); } - const PassInfo* info = lovrPassGetInfo(pass); - if (info->canvas.depth.format || info->canvas.depth.texture) { lua_pushnumber(L, depth); lua_setfield(L, -2, "depth");