panfrost_bo_unreference(shader_state->bo);
shader_state->bo = NULL;
}
+ free(cso->variants);
free(so);
}
if (variant == -1) {
/* No variant matched, so create a new one */
variant = variants->variant_count++;
- assert(variants->variant_count < MAX_SHADER_VARIANTS);
+
+ if (variants->variant_count > variants->variant_space) {
+ unsigned old_space = variants->variant_space;
+
+ variants->variant_space *= 2;
+ if (variants->variant_space == 0)
+ variants->variant_space = 1;
+
+ /* Arbitrary limit to stop runaway programs from
+ * creating an unbounded number of shader variants. */
+ assert(variants->variant_space < 1024);
+
+ unsigned msize = sizeof(struct panfrost_shader_state);
+ variants->variants = realloc(variants->variants,
+ variants->variant_space * msize);
+
+ memset(&variants->variants[old_space], 0,
+ (variants->variant_space - old_space) * msize);
+ }
struct panfrost_shader_state *v =
&variants->variants[variant];
/* Variants bundle together to form the backing CSO, bundling multiple
* shaders with varying emulated features baked in (alpha test
* parameters, etc) */
-#define MAX_SHADER_VARIANTS 8
/* A shader state corresponds to the actual, current variant of the shader */
struct panfrost_shader_state {
struct pipe_compute_state cbase;
};
- struct panfrost_shader_state variants[MAX_SHADER_VARIANTS];
+ struct panfrost_shader_state *variants;
+ unsigned variant_space;
+
unsigned variant_count;
/* The current active variant */