*/
#include "zink_compiler.h"
+#include "zink_program.h"
#include "zink_screen.h"
#include "nir_to_spirv/nir_to_spirv.h"
{
struct zink_shader *ret = CALLOC_STRUCT(zink_shader);
+ ret->programs = _mesa_pointer_set_create(NULL);
+
NIR_PASS_V(nir, nir_lower_uniforms_to_ubo, 1);
NIR_PASS_V(nir, nir_lower_clip_halfz);
NIR_PASS_V(nir, nir_lower_regs_to_ssa);
zink_shader_free(struct zink_screen *screen, struct zink_shader *shader)
{
vkDestroyShaderModule(screen->dev, shader->shader_module, NULL);
+ set_foreach(shader->programs, entry) {
+ zink_gfx_program_remove_shader((void*)entry->key, shader);
+ }
+ _mesa_set_destroy(shader->programs, NULL);
FREE(shader);
}
#include "util/set.h"
#include "util/u_debug.h"
#include "util/u_memory.h"
+#include "tgsi/tgsi_from_mesa.h"
static VkDescriptorSetLayout
create_desc_set_layout(VkDevice dev,
goto fail;
}
- for (int i = 0; i < PIPE_SHADER_TYPES - 1; ++i)
+ for (int i = 0; i < PIPE_SHADER_TYPES - 1; ++i) {
prog->stages[i] = stages[i];
+ if (stages[i])
+ _mesa_set_add(stages[i]->programs, prog);
+ }
prog->dsl = create_desc_set_layout(screen->dev, stages,
&prog->num_descriptors);
return NULL;
}
+void
+zink_gfx_program_remove_shader(struct zink_gfx_program *prog, struct zink_shader *shader)
+{
+ enum pipe_shader_type p_stage = pipe_shader_type_from_mesa(shader->info.stage);
+
+ assert(prog->stages[p_stage] == shader);
+ prog->stages[p_stage] = NULL;
+ _mesa_set_remove_key(shader->programs, prog);
+}
+
void
zink_destroy_gfx_program(struct zink_screen *screen,
struct zink_gfx_program *prog)
if (prog->dsl)
vkDestroyDescriptorSetLayout(screen->dev, prog->dsl, NULL);
+ for (int i = 0; i < PIPE_SHADER_TYPES - 1; ++i) {
+ if (prog->stages[i])
+ zink_gfx_program_remove_shader(prog, prog->stages[i]);
+ }
+
/* unref all used render-passes */
if (prog->render_passes) {
set_foreach(prog->render_passes, entry) {