Compare commits

...

3 Commits

Author SHA1 Message Date
bjorn 24fd9e0c04 gpu: properly cast device to uintptr_t; 2022-06-26 00:46:11 -07:00
bjorn ae4d7156fd lovr.graphics.submit ignores falsy values; 2022-06-26 00:45:49 -07:00
bjorn 7f22e18533 Error better when Buffer field is missing type; 2022-06-25 23:43:24 -07:00
2 changed files with 13 additions and 7 deletions

View File

@ -324,6 +324,7 @@ static void luax_checkbufferformat(lua_State* L, int index, BufferInfo* info) {
lua_rawgeti(L, index, i + 1);
if (lua_istable(L, -1)) {
lua_getfield(L, -1, "type");
lovrAssert(lua_type(L, -1) == LUA_TSTRING, "When given as a table, Buffer fields must have a 'type' key.");
field->type = luax_checkfieldtype(L, -1, &field->hash);
lua_pop(L, 1);
@ -554,21 +555,26 @@ static int l_lovrGraphicsInit(lua_State* L) {
static int l_lovrGraphicsSubmit(lua_State* L) {
bool table = lua_istable(L, 1);
int count = table ? luax_len(L, 1) : lua_gettop(L);
int length = table ? luax_len(L, 1) : lua_gettop(L);
uint32_t count = 0;
Pass* stack[8];
Pass** passes = (size_t) count > COUNTOF(stack) ? malloc(count * sizeof(Pass*)) : stack;
Pass** passes = (size_t) length > COUNTOF(stack) ? malloc(length * sizeof(Pass*)) : stack;
lovrAssert(passes, "Out of memory");
if (table) {
for (int i = 0; i < count; i++) {
for (int i = 0; i < length; i++) {
lua_rawgeti(L, 1, i + 1);
passes[i] = luax_checktype(L, -1, Pass);
if (lua_toboolean(L, -1)) {
passes[count++] = luax_checktype(L, -1, Pass);
}
lua_pop(L, 1);
}
} else {
for (int i = 0; i < count; i++) {
passes[i] = luax_checktype(L, i + 1, Pass);
for (int i = 0; i < length; i++) {
if (lua_toboolean(L, i + 1)) {
passes[count++] = luax_checktype(L, i + 1, Pass);
}
}
}

View File

@ -1870,7 +1870,7 @@ bool gpu_init(gpu_config* config) {
};
if (state.config.vk.createDevice) {
VK(state.config.vk.createDevice(state.instance, &deviceInfo, NULL, &state.device, (void*) vkGetInstanceProcAddr), "Device creation failed") return gpu_destroy(), false;
VK(state.config.vk.createDevice(state.instance, &deviceInfo, NULL, (uintptr_t) &state.device, (void*) vkGetInstanceProcAddr), "Device creation failed") return gpu_destroy(), false;
} else {
VK(vkCreateDevice(state.adapter, &deviceInfo, NULL, &state.device), "Device creation failed") return gpu_destroy(), false;
}