[Mesa-dev] [PATCH] glsl_to_tgsi: v2 Invalidate and revalidate uniform backing storage

Alex Deucher alexdeucher at gmail.com
Mon Jan 2 20:20:50 PST 2012


On Mon, Jan 2, 2012 at 10:59 PM, Ian Romanick <idr at freedesktop.org> wrote:
> On 01/02/2012 08:27 AM, Alex Deucher wrote:
>>
>> On Thu, Dec 22, 2011 at 9:35 AM, Vadim Girlin<vadimgirlin at gmail.com>
>>  wrote:
>>>
>>> If glUniform1i and friends are going to dump data directly in
>>> driver-allocated, the pointers have to be updated when the storage
>>> moves.  This should fix the regressions seen with commit 7199096.
>>>
>>> I'm not sure if this is the only place that needs this treatment.  I'm
>>> a little uncertain about the various functions in st_glsl_to_tgsi that
>>> modify the TGSI IR and try to propagate changes about that up to the
>>> gl_program.  That seems sketchy to me.
>>>
>>> Signed-off-by: Ian Romanick<ian.d.romanick at intel.com>
>>>
>>> v2:
>>>
>>> Revalidate when shader_program is not NULL.
>>> Update the pointers for all _LinkedShaders.
>>> Init glsl_to_tgsi_visitor::shader_program to NULL in the
>>> get_pixel_transfer_visitor&  get_bitmap_visitor.
>>>
>>>
>>> Signed-off-by: Vadim Girlin<vadimgirlin at gmail.com>
>>> ---
>>>
>>> Based on the patch from Ian Romanick:
>>> http://lists.freedesktop.org/archives/mesa-dev/2011-November/014675.html
>>>
>>> Fixes uniform regressions with r600g (and probably other drivers)
>>> after commit 719909698c67c287a393d2380278e7b7495ae018
>>
>>
>>
>> Are there any objections to pushing this patch?
>
>
> It seems okay to me.  I'll assume that it has received some testing and
> fixes things? :)
>

Indeed:
https://bugs.freedesktop.org/show_bug.cgi?id=43125

Alex

>> Alex
>>
>>>
>>> Tested on evergreen with r600.tests: no regressions.
>>>
>>>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   25
>>> +++++++++++++++++++++++++
>>>  1 files changed, 25 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>>> b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>>> index 77aa0d1..fce92bb 100644
>>> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>>> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>>> @@ -3708,6 +3708,7 @@ get_pixel_transfer_visitor(struct
>>> st_fragment_program *fp,
>>>    /* Copy attributes of the glsl_to_tgsi_visitor in the original shader.
>>> */
>>>    v->ctx = original->ctx;
>>>    v->prog = prog;
>>> +   v->shader_program = NULL;
>>>    v->glsl_version = original->glsl_version;
>>>    v->native_integers = original->native_integers;
>>>    v->options = original->options;
>>> @@ -3837,6 +3838,7 @@ get_bitmap_visitor(struct st_fragment_program *fp,
>>>    /* Copy attributes of the glsl_to_tgsi_visitor in the original shader.
>>> */
>>>    v->ctx = original->ctx;
>>>    v->prog = prog;
>>> +   v->shader_program = NULL;
>>>    v->glsl_version = original->glsl_version;
>>>    v->native_integers = original->native_integers;
>>>    v->options = original->options;
>>> @@ -4550,6 +4552,15 @@ st_translate_program(
>>>    t->pointSizeOutIndex = -1;
>>>    t->prevInstWrotePointSize = GL_FALSE;
>>>
>>> +   if (program->shader_program) {
>>> +      for (i = 0; i<  program->shader_program->NumUserUniformStorage;
>>> i++) {
>>> +         struct gl_uniform_storage *const storage =
>>> +&program->shader_program->UniformStorage[i];
>>>
>>> +
>>> +         _mesa_uniform_detach_all_driver_storage(storage);
>>> +      }
>>> +   }
>>> +
>>>    /*
>>>     * Declare input attributes.
>>>     */
>>> @@ -4776,6 +4787,20 @@ st_translate_program(
>>>                        t->insn[t->labels[i].branch_target]);
>>>    }
>>>
>>> +   if (program->shader_program) {
>>> +      /* This has to be done last.  Any operation the can cause
>>> +       * prog->ParameterValues to get reallocated (e.g., anything that
>>> adds a
>>> +       * program constant) has to happen before creating this linkage.
>>> +       */
>>> +      for (unsigned i = 0; i<  MESA_SHADER_TYPES; i++) {
>>> +         if (program->shader_program->_LinkedShaders[i] == NULL)
>>> +            continue;
>>> +
>>> +         _mesa_associate_uniform_storage(ctx, program->shader_program,
>>> +
>>> program->shader_program->_LinkedShaders[i]->Program->Parameters);
>>> +      }
>>> +   }
>>> +
>>>  out:
>>>    if (t) {
>>>       FREE(t->insn);
>>> --
>>> 1.7.7.4
>>>
>>> _______________________________________________
>>> mesa-dev mailing list
>>> mesa-dev at lists.freedesktop.org
>>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list