Fix Pass:setShader(nil);
@@ -2471,6 +2471,7 @@ void lovrPassSetShader(Pass* pass, Shader* shader) {
if (shader == previous) return;
// Clear any bindings for resources that share the same slot but have different types
+ if (shader) {
if (previous) {
for (uint32_t i = 0, j = 0; i < previous->resourceCount && j < shader->resourceCount;) {
if (previous->resources[i].binding < shader->resources[j].binding) {
@@ -2518,13 +2519,14 @@ void lovrPassSetShader(Pass* pass, Shader* shader) {
pass->bindingsDirty = true;
}
- lovrRetain(shader);
- lovrRelease(previous, lovrShaderDestroy);
-
- pass->pipeline->shader = shader;
pass->pipeline->info.shader = shader->gpu;
pass->pipeline->info.flags = shader->flags;
pass->pipeline->info.flagCount = shader->overrideCount;
+ }
+
+ lovrRetain(shader);
+ lovrRelease(previous, lovrShaderDestroy);
+ pass->pipeline->shader = shader;
pass->pipeline->dirty = true;
}
