Skip to content

Commit

Permalink
renderer/command_builder: be robust against shader load failure
Browse files Browse the repository at this point in the history
Signed-off-by: Yuxuan Shui <[email protected]>
  • Loading branch information
yshui committed Aug 13, 2024
1 parent fda04bd commit c3e18a6
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,6 @@ bool load_plugin(const char *name, const char *include_dir) {
return handle != NULL;
}

struct shader_info null_shader = {0};

bool parse_config(options_t *opt, const char *config_file) {
// clang-format off
*opt = (struct options){
Expand Down
2 changes: 0 additions & 2 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ win_options_no_damage(const struct window_options *a, const struct window_option
return memcmp(a, b, offsetof(struct window_options, animations)) == 0;
}

extern struct shader_info null_shader;

/// Structure representing all options.
typedef struct options {
// === Config ===
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/command_builder.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ commands_for_window_body(struct layer *layer, struct backend_command *cmd_base,
if (layer->options.corner_radius > 0) {
win_region_remove_corners(w, layer->window.origin, &cmd->opaque_region);
}
struct shader_info *shader = &null_shader;
struct shader_info *shader = NULL;
if (layer->options.shader != NULL) {
HASH_FIND_STR(shaders, layer->options.shader, shader);
}
Expand All @@ -70,7 +70,7 @@ commands_for_window_body(struct layer *layer, struct backend_command *cmd_base,
.dim = dim,
.scale = layer->scale,
.effective_size = layer->window.size,
.shader = shader->backend_shader,
.shader = shader != NULL ? shader->backend_shader : NULL,
.color_inverted = layer->options.invert_color,
.source_mask = NULL,
.max_brightness = max_brightness,
Expand Down

0 comments on commit c3e18a6

Please sign in to comment.