mesa/st: move program new/delete into mesa
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14700>
This commit is contained in:
@@ -47,8 +47,6 @@
|
||||
#include "util/set.h"
|
||||
#include "util/u_memory.h"
|
||||
|
||||
#include "state_tracker/st_cb_program.h"
|
||||
|
||||
static void
|
||||
free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared);
|
||||
|
||||
@@ -195,7 +193,7 @@ delete_program_cb(void *data, void *userData)
|
||||
if(prog != &_mesa_DummyProgram) {
|
||||
assert(prog->RefCount == 1); /* should only be referenced by hash table */
|
||||
prog->RefCount = 0; /* now going away */
|
||||
st_delete_program(ctx, prog);
|
||||
_mesa_delete_program(ctx, prog);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -44,7 +44,9 @@
|
||||
#include "util/ralloc.h"
|
||||
#include "util/u_atomic.h"
|
||||
|
||||
#include "state_tracker/st_cb_program.h"
|
||||
#include "state_tracker/st_program.h"
|
||||
#include "state_tracker/st_glsl_to_tgsi.h"
|
||||
#include "state_tracker/st_context.h"
|
||||
|
||||
/**
|
||||
* A pointer to this dummy program is put into the hash table when
|
||||
@@ -217,6 +219,24 @@ _mesa_init_gl_program(struct gl_program *prog, gl_shader_stage stage,
|
||||
return prog;
|
||||
}
|
||||
|
||||
struct gl_program *
|
||||
_mesa_new_program(struct gl_context *ctx, gl_shader_stage stage, GLuint id,
|
||||
bool is_arb_asm)
|
||||
{
|
||||
struct gl_program *prog;
|
||||
|
||||
switch (stage) {
|
||||
case MESA_SHADER_VERTEX:
|
||||
prog = (struct gl_program*)rzalloc(NULL, struct gl_vertex_program);
|
||||
break;
|
||||
default:
|
||||
prog = rzalloc(NULL, struct gl_program);
|
||||
break;
|
||||
}
|
||||
|
||||
return _mesa_init_gl_program(prog, stage, id, is_arb_asm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a program and remove it from the hash table, ignoring the
|
||||
* reference count.
|
||||
@@ -224,10 +244,17 @@ _mesa_init_gl_program(struct gl_program *prog, gl_shader_stage stage,
|
||||
void
|
||||
_mesa_delete_program(struct gl_context *ctx, struct gl_program *prog)
|
||||
{
|
||||
(void) ctx;
|
||||
struct st_context *st = st_context(ctx);
|
||||
assert(prog);
|
||||
assert(prog->RefCount==0);
|
||||
|
||||
st_release_variants(st, prog);
|
||||
|
||||
if (prog->glsl_to_tgsi)
|
||||
free_glsl_to_tgsi_visitor(prog->glsl_to_tgsi);
|
||||
|
||||
free(prog->serialized_nir);
|
||||
|
||||
if (prog == &_mesa_DummyProgram)
|
||||
return;
|
||||
|
||||
@@ -302,7 +329,7 @@ _mesa_reference_program_(struct gl_context *ctx,
|
||||
if (p_atomic_dec_zero(&oldProg->RefCount)) {
|
||||
assert(ctx);
|
||||
_mesa_reference_shader_program_data(&oldProg->sh.data, NULL);
|
||||
st_delete_program(ctx, oldProg);
|
||||
_mesa_delete_program(ctx, oldProg);
|
||||
}
|
||||
|
||||
*ptr = NULL;
|
||||
|
@@ -66,6 +66,10 @@ extern struct gl_program *
|
||||
_mesa_init_gl_program(struct gl_program *prog, gl_shader_stage stage,
|
||||
GLuint id, bool is_arb_asm);
|
||||
|
||||
extern struct gl_program *
|
||||
_mesa_new_program(struct gl_context *ctx, gl_shader_stage stage, GLuint id,
|
||||
bool is_arb_asm);
|
||||
|
||||
extern void
|
||||
_mesa_delete_program(struct gl_context *ctx, struct gl_program *prog);
|
||||
|
||||
|
@@ -48,46 +48,6 @@
|
||||
#include "st_atifs_to_nir.h"
|
||||
#include "st_util.h"
|
||||
|
||||
|
||||
/**
|
||||
* Called via ctx->Driver.NewProgram() to allocate a new vertex or
|
||||
* fragment program.
|
||||
*/
|
||||
static struct gl_program *
|
||||
st_new_program(struct gl_context *ctx, gl_shader_stage stage, GLuint id,
|
||||
bool is_arb_asm)
|
||||
{
|
||||
struct gl_program *prog;
|
||||
|
||||
switch (stage) {
|
||||
case MESA_SHADER_VERTEX:
|
||||
prog = (struct gl_program*)rzalloc(NULL, struct gl_vertex_program);
|
||||
break;
|
||||
default:
|
||||
prog = rzalloc(NULL, struct gl_program);
|
||||
break;
|
||||
}
|
||||
|
||||
return _mesa_init_gl_program(prog, stage, id, is_arb_asm);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
st_delete_program(struct gl_context *ctx, struct gl_program *prog)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
|
||||
st_release_variants(st, prog);
|
||||
|
||||
if (prog->glsl_to_tgsi)
|
||||
free_glsl_to_tgsi_visitor(prog->glsl_to_tgsi);
|
||||
|
||||
free(prog->serialized_nir);
|
||||
|
||||
/* delete base class */
|
||||
_mesa_delete_program( ctx, prog );
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the program's text/code is changed. We have to free
|
||||
* all shader variants and corresponding gallium shaders when this happens.
|
||||
@@ -133,5 +93,5 @@ st_program_string_notify( struct gl_context *ctx,
|
||||
void
|
||||
st_init_program_functions(struct dd_function_table *functions)
|
||||
{
|
||||
functions->NewProgram = st_new_program;
|
||||
functions->NewProgram = _mesa_new_program;
|
||||
}
|
||||
|
@@ -36,7 +36,6 @@ struct dd_function_table;
|
||||
|
||||
extern void
|
||||
st_init_program_functions(struct dd_function_table *functions);
|
||||
void st_delete_program(struct gl_context *ctx, struct gl_program *prog);
|
||||
GLboolean st_program_string_notify(struct gl_context *ctx,
|
||||
GLenum target,
|
||||
struct gl_program *prog);
|
||||
|
Reference in New Issue
Block a user