[Mesa-dev] [PATCH] st/mesa. fix crash when glBlitFramebuffer is the first function called
Marek Olšák
maraeo at gmail.com
Mon Jun 29 07:08:35 PDT 2015
Ping
On Fri, Jun 26, 2015 at 11:01 AM, Marek Olšák <maraeo at gmail.com> wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> No states are initialized at that point yet.
>
> Cc: 10.5 10.6 <mesa-stable at lists.freedesktop.org>
> ---
> src/mesa/state_tracker/st_atom_constbuf.c | 14 ++++++++------
> src/mesa/state_tracker/st_atom_sampler.c | 30 +++++++++++++++++-------------
> src/mesa/state_tracker/st_atom_shader.c | 8 ++++++--
> src/mesa/state_tracker/st_atom_texture.c | 19 +++++++++++--------
> 4 files changed, 42 insertions(+), 29 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
> index a54e0d9..a31765c 100644
> --- a/src/mesa/state_tracker/st_atom_constbuf.c
> +++ b/src/mesa/state_tracker/st_atom_constbuf.c
> @@ -117,10 +117,11 @@ void st_upload_constants( struct st_context *st,
> */
> static void update_vs_constants(struct st_context *st )
> {
> - struct st_vertex_program *vp = st->vp;
> - struct gl_program_parameter_list *params = vp->Base.Base.Parameters;
> + if (st->vp) {
> + struct gl_program_parameter_list *params = st->vp->Base.Base.Parameters;
>
> - st_upload_constants( st, params, PIPE_SHADER_VERTEX );
> + st_upload_constants(st, params, PIPE_SHADER_VERTEX);
> + }
> }
>
>
> @@ -140,10 +141,11 @@ const struct st_tracked_state st_update_vs_constants = {
> */
> static void update_fs_constants(struct st_context *st )
> {
> - struct st_fragment_program *fp = st->fp;
> - struct gl_program_parameter_list *params = fp->Base.Base.Parameters;
> + if (st->fp) {
> + struct gl_program_parameter_list *params = st->fp->Base.Base.Parameters;
>
> - st_upload_constants( st, params, PIPE_SHADER_FRAGMENT );
> + st_upload_constants(st, params, PIPE_SHADER_FRAGMENT);
> + }
> }
>
>
> diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
> index b68eb16..96ba3f4 100644
> --- a/src/mesa/state_tracker/st_atom_sampler.c
> +++ b/src/mesa/state_tracker/st_atom_sampler.c
> @@ -284,19 +284,23 @@ update_samplers(struct st_context *st)
> {
> const struct gl_context *ctx = st->ctx;
>
> - update_shader_samplers(st,
> - PIPE_SHADER_FRAGMENT,
> - &ctx->FragmentProgram._Current->Base,
> - ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits,
> - st->state.samplers[PIPE_SHADER_FRAGMENT],
> - &st->state.num_samplers[PIPE_SHADER_FRAGMENT]);
> -
> - update_shader_samplers(st,
> - PIPE_SHADER_VERTEX,
> - &ctx->VertexProgram._Current->Base,
> - ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits,
> - st->state.samplers[PIPE_SHADER_VERTEX],
> - &st->state.num_samplers[PIPE_SHADER_VERTEX]);
> + if (ctx->FragmentProgram._Current) {
> + update_shader_samplers(st,
> + PIPE_SHADER_FRAGMENT,
> + &ctx->FragmentProgram._Current->Base,
> + ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits,
> + st->state.samplers[PIPE_SHADER_FRAGMENT],
> + &st->state.num_samplers[PIPE_SHADER_FRAGMENT]);
> + }
> +
> + if (ctx->VertexProgram._Current) {
> + update_shader_samplers(st,
> + PIPE_SHADER_VERTEX,
> + &ctx->VertexProgram._Current->Base,
> + ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits,
> + st->state.samplers[PIPE_SHADER_VERTEX],
> + &st->state.num_samplers[PIPE_SHADER_VERTEX]);
> + }
>
> if (ctx->GeometryProgram._Current) {
> update_shader_samplers(st,
> diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c
> index ad8d262..9ce71b2 100644
> --- a/src/mesa/state_tracker/st_atom_shader.c
> +++ b/src/mesa/state_tracker/st_atom_shader.c
> @@ -77,7 +77,9 @@ update_fp( struct st_context *st )
> struct st_fragment_program *stfp;
> struct st_fp_variant_key key;
>
> - assert(st->ctx->FragmentProgram._Current);
> + if (!st->ctx->FragmentProgram._Current)
> + return;
> +
> stfp = st_fragment_program(st->ctx->FragmentProgram._Current);
> assert(stfp->Base.Base.Target == GL_FRAGMENT_PROGRAM_ARB);
>
> @@ -132,7 +134,9 @@ update_vp( struct st_context *st )
> /* find active shader and params -- Should be covered by
> * ST_NEW_VERTEX_PROGRAM
> */
> - assert(st->ctx->VertexProgram._Current);
> + if (!st->ctx->VertexProgram._Current)
> + return;
> +
> stvp = st_vertex_program(st->ctx->VertexProgram._Current);
> assert(stvp->Base.Base.Target == GL_VERTEX_PROGRAM_ARB);
>
> diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
> index 04ba864..bcdeaa5 100644
> --- a/src/mesa/state_tracker/st_atom_texture.c
> +++ b/src/mesa/state_tracker/st_atom_texture.c
> @@ -433,7 +433,8 @@ update_vertex_textures(struct st_context *st)
> {
> const struct gl_context *ctx = st->ctx;
>
> - if (ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits > 0) {
> + if (ctx->VertexProgram._Current &&
> + ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits > 0) {
> update_textures(st,
> PIPE_SHADER_VERTEX,
> &ctx->VertexProgram._Current->Base,
> @@ -449,12 +450,14 @@ update_fragment_textures(struct st_context *st)
> {
> const struct gl_context *ctx = st->ctx;
>
> - update_textures(st,
> - PIPE_SHADER_FRAGMENT,
> - &ctx->FragmentProgram._Current->Base,
> - ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits,
> - st->state.sampler_views[PIPE_SHADER_FRAGMENT],
> - &st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]);
> + if (ctx->FragmentProgram._Current) {
> + update_textures(st,
> + PIPE_SHADER_FRAGMENT,
> + &ctx->FragmentProgram._Current->Base,
> + ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits,
> + st->state.sampler_views[PIPE_SHADER_FRAGMENT],
> + &st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]);
> + }
> }
>
>
> @@ -516,7 +519,7 @@ finalize_textures(struct st_context *st)
> st->missing_textures = GL_FALSE;
>
> for (su = 0; su < ctx->Const.MaxTextureCoordUnits; su++) {
> - if (fprog->Base.SamplersUsed & (1 << su)) {
> + if (fprog && fprog->Base.SamplersUsed & (1 << su)) {
> const GLuint texUnit = fprog->Base.SamplerUnits[su];
> struct gl_texture_object *texObj
> = ctx->Texture.Unit[texUnit]._Current;
> --
> 2.1.0
>
More information about the mesa-dev
mailing list