gallium: added cso_delete_vertex_fragment_shader() functions
The state tracker now uses these functions to free shaders, rather than the pipe->delete_vs/fs-state() functions. Before, we could get in a situation where we free() a shader and happen to alloc() a new one at the same address. The cso_set_vertex/fragment_shader() function would no-op the state change since the pointers were the same. This led to problems elsewhere, of course. The new delete functions null-out the CSO's current shader pointers.
This commit is contained in:
@@ -471,6 +471,8 @@ void cso_restore_rasterizer(struct cso_context *ctx)
|
||||
ctx->rasterizer_saved = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
enum pipe_error cso_set_fragment_shader_handle(struct cso_context *ctx,
|
||||
void *handle )
|
||||
{
|
||||
@@ -481,6 +483,13 @@ enum pipe_error cso_set_fragment_shader_handle(struct cso_context *ctx,
|
||||
return PIPE_OK;
|
||||
}
|
||||
|
||||
void cso_delete_fragment_shader(struct cso_context *ctx, void *handle )
|
||||
{
|
||||
if (handle == ctx->fragment_shader)
|
||||
ctx->pipe->bind_fs_state(ctx->pipe, NULL);
|
||||
ctx->pipe->delete_fs_state(ctx->pipe, handle);
|
||||
ctx->fragment_shader = NULL;
|
||||
}
|
||||
|
||||
/* Not really working:
|
||||
*/
|
||||
@@ -553,6 +562,14 @@ enum pipe_error cso_set_vertex_shader_handle(struct cso_context *ctx,
|
||||
return PIPE_OK;
|
||||
}
|
||||
|
||||
void cso_delete_vertex_shader(struct cso_context *ctx, void *handle )
|
||||
{
|
||||
if (handle == ctx->vertex_shader)
|
||||
ctx->pipe->bind_vs_state(ctx->pipe, NULL);
|
||||
ctx->pipe->delete_vs_state(ctx->pipe, handle);
|
||||
ctx->vertex_shader = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Not really working:
|
||||
*/
|
||||
|
||||
@@ -99,16 +99,22 @@ void cso_restore_sampler_textures( struct cso_context *cso );
|
||||
*/
|
||||
enum pipe_error cso_set_fragment_shader_handle(struct cso_context *ctx,
|
||||
void *handle );
|
||||
void cso_delete_fragment_shader(struct cso_context *ctx, void *handle );
|
||||
/*
|
||||
enum pipe_error cso_set_fragment_shader( struct cso_context *cso,
|
||||
const struct pipe_shader_state *shader );
|
||||
*/
|
||||
void cso_save_fragment_shader(struct cso_context *cso);
|
||||
void cso_restore_fragment_shader(struct cso_context *cso);
|
||||
|
||||
|
||||
enum pipe_error cso_set_vertex_shader_handle(struct cso_context *ctx,
|
||||
void *handle );
|
||||
void cso_delete_vertex_shader(struct cso_context *ctx, void *handle );
|
||||
/*
|
||||
enum pipe_error cso_set_vertex_shader( struct cso_context *cso,
|
||||
const struct pipe_shader_state *shader );
|
||||
*/
|
||||
void cso_save_vertex_shader(struct cso_context *cso);
|
||||
void cso_restore_vertex_shader(struct cso_context *cso);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user