diff --git a/gpu.c b/gpu.c index 9f18333..b5a9794 100644 --- a/gpu.c +++ b/gpu.c @@ -1192,7 +1192,7 @@ JSC_CCALL(cmd_render_pass, uint32_t colorCount = JS_ArrayLength(js, colorTargetsVal); SDL_GPUColorTargetInfo colortars[colorCount]; - SDL_GPUDepthStencilTargetInfo depthtar; + SDL_GPUDepthStencilTargetInfo depthtar = (SDL_GPUDepthStencilTargetInfo){0}; int has_depth = 0; // Fill colorInfos from JS array @@ -1204,7 +1204,7 @@ JSC_CCALL(cmd_render_pass, // Optional depth_stencil JSValue depthval = JS_GetPropertyStr(js, passObj, "depth_stencil"); - if (!JS_IsNull(depthval)) { + if (JS_IsObject(depthval)) { has_depth = 1; JS_GETPROP(js, depthtar.texture, depthval, texture, SDL_GPUTexture) JS_GETPROP(js, depthtar.load_op, depthval, load, SDL_GPULoadOp) @@ -1213,6 +1213,9 @@ JSC_CCALL(cmd_render_pass, JS_GETPROP(js, depthtar.stencil_store_op, depthval, stencil_store, SDL_GPUStoreOp) JS_GETPROP(js,depthtar.clear_depth, depthval, clear, number) JS_GETPROP(js,depthtar.clear_stencil,depthval,clear_stencil,number) + + // If texture was null/invalid, treat as no depth attachment. + if (!depthtar.texture) has_depth = 0; } JS_FreeValue(js, depthval); @@ -1380,7 +1383,7 @@ JSC_CCALL(cmd_swapchain_pass, colorTargetInfo.texture = swapchainTexture; - SDL_GPUDepthStencilTargetInfo depthtar; + SDL_GPUDepthStencilTargetInfo depthtar = (SDL_GPUDepthStencilTargetInfo){0}; int has_depth = 0; JSValue depthval = JS_GetPropertyStr(js, passObj, "depth_stencil"); @@ -1393,6 +1396,9 @@ JSC_CCALL(cmd_swapchain_pass, JS_GETPROP(js, depthtar.stencil_store_op, depthval, stencil_store, SDL_GPUStoreOp) JS_GETPROP(js, depthtar.clear_depth, depthval, clear, number) JS_GETPROP(js, depthtar.clear_stencil, depthval, clear_stencil, number) + + // If texture was null/invalid, treat as no depth attachment. + if (!depthtar.texture) has_depth = 0; } JS_FreeValue(js, depthval); diff --git a/video.c b/video.c index 0bf9673..df8f4a3 100644 --- a/video.c +++ b/video.c @@ -202,8 +202,6 @@ static JSValue js_SDL_Window_constructor(JSContext *js, JSValueConst new_target, } JS_FreeValue(js, text_input); - printf("created window %p\n", window); - return window_obj; }