[Mesa-dev] [PATCH] st/nine: Fix a regression and syntax cleanup

Edmondo Tommasina edmondo.tommasina at gmail.com
Mon May 22 19:01:01 UTC 2017


The crash with STALKER: CoC is fixed with this patch.

Tested-by: Edmondo Tommasina <edmondo.tommasina at gmail.com>

Thanks
edmondo


On Mon, May 22, 2017 at 12:22 AM, Axel Davy <axel.davy at ens.fr> wrote:
> A few cleanups and in particular initializing properly
> the new pipe_draw_info fields.
> This should fix the regression caused by
> 330d0607ed60fd3edca192e54b4246310f06652f
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101088
>
> Signed-off-by: Axel Davy <axel.davy at ens.fr>
> ---
>  src/gallium/state_trackers/nine/device9.c      |  2 +-
>  src/gallium/state_trackers/nine/indexbuffer9.c |  8 ++------
>  src/gallium/state_trackers/nine/indexbuffer9.h |  5 ++---
>  src/gallium/state_trackers/nine/nine_state.c   | 20 +++++++++++---------
>  4 files changed, 16 insertions(+), 19 deletions(-)
>
> diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
> index db33fdd580..37880405e9 100644
> --- a/src/gallium/state_trackers/nine/device9.c
> +++ b/src/gallium/state_trackers/nine/device9.c
> @@ -2927,7 +2927,7 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This,
>                                                             ibuf,
>                                                             ibuf ? NULL : (void*)pIndexData,
>                                                             index_offset,
> -                                                          index_size);
> +                                                           index_size);
>      NineAfterDraw(This);
>
>      pipe_vertex_buffer_unreference(&vbuf);
> diff --git a/src/gallium/state_trackers/nine/indexbuffer9.c b/src/gallium/state_trackers/nine/indexbuffer9.c
> index d5f5492563..e73d29b5bd 100644
> --- a/src/gallium/state_trackers/nine/indexbuffer9.c
> +++ b/src/gallium/state_trackers/nine/indexbuffer9.c
> @@ -49,9 +49,6 @@ NineIndexBuffer9_ctor( struct NineIndexBuffer9 *This,
>      if (FAILED(hr))
>          return hr;
>
> -    This->buffer = NULL;
> -    This->offset = 0;
> -
>      switch (pDesc->Format) {
>      case D3DFMT_INDEX16: This->index_size = 2; break;
>      case D3DFMT_INDEX32: This->index_size = 4; break;
> @@ -73,11 +70,10 @@ NineIndexBuffer9_dtor( struct NineIndexBuffer9 *This )
>  }
>
>  struct pipe_resource *
> -NineIndexBuffer9_GetBuffer( struct NineIndexBuffer9 *This )
> +NineIndexBuffer9_GetBuffer( struct NineIndexBuffer9 *This, unsigned *offset )
>  {
>      /* The resource may change */
> -    This->buffer = NineBuffer9_GetResource(&This->base, &This->offset);
> -    return This->buffer;
> +    return NineBuffer9_GetResource(&This->base, offset);
>  }
>
>  HRESULT NINE_WINAPI
> diff --git a/src/gallium/state_trackers/nine/indexbuffer9.h b/src/gallium/state_trackers/nine/indexbuffer9.h
> index 0efad7f5f1..e688488da8 100644
> --- a/src/gallium/state_trackers/nine/indexbuffer9.h
> +++ b/src/gallium/state_trackers/nine/indexbuffer9.h
> @@ -37,8 +37,6 @@ struct NineIndexBuffer9
>      struct NineBuffer9 base;
>
>      /* g3d stuff */
> -    struct pipe_resource *buffer;
> -    unsigned offset;
>      unsigned index_size;
>
>      D3DINDEXBUFFER_DESC desc;
> @@ -65,7 +63,8 @@ NineIndexBuffer9_dtor( struct NineIndexBuffer9 *This );
>  /*** Nine private ***/
>
>  struct pipe_resource *
> -NineIndexBuffer9_GetBuffer( struct NineIndexBuffer9 *This );
> +NineIndexBuffer9_GetBuffer( struct NineIndexBuffer9 *This,
> +                            unsigned *offset );
>
>  /*** Direct3D public ***/
>
> diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
> index 0fc4c8315a..30935760ae 100644
> --- a/src/gallium/state_trackers/nine/nine_state.c
> +++ b/src/gallium/state_trackers/nine/nine_state.c
> @@ -1575,12 +1575,11 @@ nine_context_set_indices(struct NineDevice9 *device,
>  {
>      struct pipe_resource *res = NULL;
>      UINT IndexSize = 0;
> -    UINT OffsetInBytes = 0;
> +    unsigned OffsetInBytes = 0;
>
>      if (idxbuf) {
> -        res = NineIndexBuffer9_GetBuffer(idxbuf);
> +        res = NineIndexBuffer9_GetBuffer(idxbuf, &OffsetInBytes);
>          IndexSize = idxbuf->index_size;
> -        OffsetInBytes = idxbuf->offset;
>      }
>
>      nine_context_set_indices_apply(device, res, IndexSize, OffsetInBytes);
> @@ -2540,6 +2539,7 @@ init_draw_info(struct pipe_draw_info *info,
>      if (dev->context.stream_instancedata_mask & dev->context.stream_usage_mask)
>          info->instance_count = MAX2(dev->context.stream_freq[0] & 0x7FFFFF, 1);
>      info->primitive_restart = FALSE;
> +    info->has_user_indices = FALSE;
>      info->restart_index = 0;
>      info->count_from_stream_output = NULL;
>      info->indirect = NULL;
> @@ -2561,17 +2561,18 @@ CSMT_ITEM_NO_WAIT(nine_context_draw_primitive,
>      info.index_bias = 0;
>      info.min_index = info.start;
>      info.max_index = info.count - 1;
> +    info.index.resource = NULL;
>
>      context->pipe->draw_vbo(context->pipe, &info);
>  }
>
>  CSMT_ITEM_NO_WAIT(nine_context_draw_indexed_primitive,
>                    ARG_VAL(D3DPRIMITIVETYPE, PrimitiveType),
> -                   ARG_VAL(INT, BaseVertexIndex),
> -                   ARG_VAL(UINT, MinVertexIndex),
> -                   ARG_VAL(UINT, NumVertices),
> -                   ARG_VAL(UINT, StartIndex),
> -                   ARG_VAL(UINT, PrimitiveCount))
> +                  ARG_VAL(INT, BaseVertexIndex),
> +                  ARG_VAL(UINT, MinVertexIndex),
> +                  ARG_VAL(UINT, NumVertices),
> +                  ARG_VAL(UINT, StartIndex),
> +                  ARG_VAL(UINT, PrimitiveCount))
>  {
>      struct nine_context *context = &device->context;
>      struct pipe_draw_info info;
> @@ -2606,6 +2607,7 @@ CSMT_ITEM_NO_WAIT(nine_context_draw_primitive_from_vtxbuf,
>      info.index_bias = 0;
>      info.min_index = 0;
>      info.max_index = info.count - 1;
> +    info.index.resource = NULL;
>
>      context->pipe->set_vertex_buffers(context->pipe, 0, 1, vtxbuf);
>
> @@ -2621,7 +2623,7 @@ CSMT_ITEM_NO_WAIT(nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf,
>                    ARG_BIND_RES(struct pipe_resource, ibuf),
>                    ARG_VAL(void *, user_ibuf),
>                    ARG_VAL(UINT, index_offset),
> -                 ARG_VAL(UINT, index_size))
> +                  ARG_VAL(UINT, index_size))
>  {
>      struct nine_context *context = &device->context;
>      struct pipe_draw_info info;
> --
> 2.13.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list