[PATCH 3/4] d3d10: Implement ShaderResource effect variable set method.

Henri Verbeet hverbeet at gmail.com
Tue Mar 24 12:40:09 CDT 2020


On Tue, 24 Mar 2020 at 17:42, Matteo Bruni <matteo.mystral at gmail.com> wrote:
> On Sat, Mar 21, 2020 at 7:31 PM Connor McAdams <conmanx360 at gmail.com> wrote:
> > @@ -5908,8 +5961,24 @@ static const struct ID3D10EffectStringVariableVtbl d3d10_effect_string_variable_
> >      d3d10_effect_string_variable_GetStringArray,
> >  };
> >
> > +static void set_shader_resource_variable(ID3D10ShaderResourceView **src, ID3D10ShaderResourceView **dst)
> > +{
> > +    if (*dst)
> > +        ID3D10ShaderResourceView_Release(*dst);
> > +    if (*src)
> > +        ID3D10ShaderResourceView_AddRef(*src);
> > +
> > +    *dst = *src;
> > +}
>
> When we have to handle something like this in other places we usually
> check that *dst != *src first, as an optimization. Also, can either of
> them be NULL?
>
It's perhaps worth pointing out that it's potentially more than an
optimisation. If *dst and *src point to the same object, there's a
risk that doing the Release() before the AddRef() ends up destroying
that object.



More information about the wine-devel mailing list