Re: [Mesa-dev] [PATCH] st/nine: make use of common uploaders v2

2017-02-20 Thread Constantine Charlamov
Version 3 sent. Sorry, I haven't figured out — I ought to add you to CC.


On 20.02.2017 22:49, Axel Davy wrote:
> On 20/02/2017 20:22, Constantine Charlamov wrote:
>> Make use of common uploaders that landed recently to Mesa
>>
>> v2: fixed formatting, broken due to thunderbird configuration
>>
>> ---
>>  src/gallium/state_trackers/nine/device9.c| 48 
>> 
>>  src/gallium/state_trackers/nine/device9.h|  5 ---
>>  src/gallium/state_trackers/nine/nine_ff.c|  8 ++---
>>  src/gallium/state_trackers/nine/nine_state.c | 48 
>> ++--
>>  4 files changed, 35 insertions(+), 74 deletions(-)
>>
>> diff --git a/src/gallium/state_trackers/nine/device9.c 
>> b/src/gallium/state_trackers/nine/device9.c
>> index b9b7a637d7..2ae8678c31 100644
>> --- a/src/gallium/state_trackers/nine/device9.c
>> +++ b/src/gallium/state_trackers/nine/device9.c
>> @@ -477,31 +477,8 @@ NineDevice9_ctor( struct NineDevice9 *This,
>>  This->driver_caps.user_cbufs = GET_PCAP(USER_CONSTANT_BUFFERS);
>>  This->driver_caps.user_sw_vbufs = 
>> This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_VERTEX_BUFFERS);
>>  This->driver_caps.user_sw_cbufs = 
>> This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_CONSTANT_BUFFERS);
>> -
>> -/* Implicit use of context pipe for vertex and index uploaded when
>> - * csmt is not active. Does not need to sync since csmt is unactive,
>> - * thus no need to call NineDevice9_GetPipe at each upload. */
> I'd like to have this comment kept somehow (though the use of context pipe is 
> not implicit anymore).
>
> I guess it should be in NineDevice9_DrawPrimitiveUP just before if 
> (!This->driver_caps.user_vbufs).
>
> It could be: csmt is unactive when user vertex or index buffers are used, 
> thus no need to call NineDevice8_GetPipe.
>
> Axel
>> -if (!This->driver_caps.user_vbufs)
>> -This->vertex_uploader = u_upload_create(This->csmt_active ?
>> -This->pipe_secondary : 
>> This->context.pipe,
>> -65536,
>> -PIPE_BIND_VERTEX_BUFFER, 
>> PIPE_USAGE_STREAM);
>> -This->vertex_sw_uploader = u_upload_create(This->pipe_sw, 65536,
>> -PIPE_BIND_VERTEX_BUFFER, 
>> PIPE_USAGE_STREAM);
>> -if (!This->driver_caps.user_ibufs)
>> -This->index_uploader = u_upload_create(This->csmt_active ?
>> -This->pipe_secondary : 
>> This->context.pipe,
>> -   128 * 1024,
>> -   PIPE_BIND_INDEX_BUFFER, 
>> PIPE_USAGE_STREAM);
>> -if (!This->driver_caps.user_cbufs) {
>> +if (!This->driver_caps.user_cbufs)
>>  This->constbuf_alignment = 
>> GET_PCAP(CONSTANT_BUFFER_OFFSET_ALIGNMENT);
>> -This->constbuf_uploader = u_upload_create(This->context.pipe, 
>> This->vs_const_size,
>> -  
>> PIPE_BIND_CONSTANT_BUFFER, PIPE_USAGE_STREAM);
>> -}
>> -
>> -This->constbuf_sw_uploader = u_upload_create(This->pipe_sw, 128 * 1024,
>> - PIPE_BIND_CONSTANT_BUFFER, 
>> PIPE_USAGE_STREAM);
>> -
>>  This->driver_caps.window_space_position_support = 
>> GET_PCAP(TGSI_VS_WINDOW_SPACE_POSITION);
>>  This->driver_caps.vs_integer = pScreen->get_shader_param(pScreen, 
>> PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_INTEGERS);
>>  This->driver_caps.ps_integer = pScreen->get_shader_param(pScreen, 
>> PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_INTEGERS);
>> @@ -552,17 +529,6 @@ NineDevice9_dtor( struct NineDevice9 *This )
>>  nine_state_clear(>state, TRUE);
>>  nine_context_clear(This);
>>  
>> -if (This->vertex_uploader)
>> -u_upload_destroy(This->vertex_uploader);
>> -if (This->index_uploader)
>> -u_upload_destroy(This->index_uploader);
>> -if (This->constbuf_uploader)
>> -u_upload_destroy(This->constbuf_uploader);
>> -if (This->vertex_sw_uploader)
>> -u_upload_destroy(This->vertex_sw_uploader);
>> -if (This->constbuf_sw_uploader)
>> -u_upload_destroy(This->constbuf_sw_uploader);
>> -
>>  nine_bind(>record, NULL);
>>  
>>  pipe_sampler_view_reference(>dummy_sampler_view, NULL);
>> @@ -2853,14 +2819,14 @@ NineDevice9_DrawPrimitiveUP( struct NineDevice9 
>> *This,
>>  vtxbuf.user_buffer = pVertexStreamZeroData;
>>  
>>  if (!This->driver_caps.user_vbufs) {
>> -u_upload_data(This->vertex_uploader,
>> +u_upload_data(This->context.pipe->stream_uploader,
>>0,
>>(prim_count_to_vertex_count(PrimitiveType, 
>> PrimitiveCount)) * VertexStreamZeroStride, /* XXX */
>>4,
>>vtxbuf.user_buffer,
>>

Re: [Mesa-dev] [PATCH] st/nine: make use of common uploaders v2

2017-02-20 Thread Axel Davy

On 20/02/2017 20:22, Constantine Charlamov wrote:

Make use of common uploaders that landed recently to Mesa

v2: fixed formatting, broken due to thunderbird configuration

---
  src/gallium/state_trackers/nine/device9.c| 48 
  src/gallium/state_trackers/nine/device9.h|  5 ---
  src/gallium/state_trackers/nine/nine_ff.c|  8 ++---
  src/gallium/state_trackers/nine/nine_state.c | 48 ++--
  4 files changed, 35 insertions(+), 74 deletions(-)

diff --git a/src/gallium/state_trackers/nine/device9.c 
b/src/gallium/state_trackers/nine/device9.c
index b9b7a637d7..2ae8678c31 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -477,31 +477,8 @@ NineDevice9_ctor( struct NineDevice9 *This,
  This->driver_caps.user_cbufs = GET_PCAP(USER_CONSTANT_BUFFERS);
  This->driver_caps.user_sw_vbufs = 
This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_VERTEX_BUFFERS);
  This->driver_caps.user_sw_cbufs = 
This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_CONSTANT_BUFFERS);
-
-/* Implicit use of context pipe for vertex and index uploaded when
- * csmt is not active. Does not need to sync since csmt is unactive,
- * thus no need to call NineDevice9_GetPipe at each upload. */
I'd like to have this comment kept somehow (though the use of context 
pipe is not implicit anymore).


I guess it should be in NineDevice9_DrawPrimitiveUP just before if 
(!This->driver_caps.user_vbufs).


It could be: csmt is unactive when user vertex or index buffers are 
used, thus no need to call NineDevice8_GetPipe.


Axel

-if (!This->driver_caps.user_vbufs)
-This->vertex_uploader = u_upload_create(This->csmt_active ?
-This->pipe_secondary : 
This->context.pipe,
-65536,
-PIPE_BIND_VERTEX_BUFFER, 
PIPE_USAGE_STREAM);
-This->vertex_sw_uploader = u_upload_create(This->pipe_sw, 65536,
-PIPE_BIND_VERTEX_BUFFER, 
PIPE_USAGE_STREAM);
-if (!This->driver_caps.user_ibufs)
-This->index_uploader = u_upload_create(This->csmt_active ?
-This->pipe_secondary : 
This->context.pipe,
-   128 * 1024,
-   PIPE_BIND_INDEX_BUFFER, 
PIPE_USAGE_STREAM);
-if (!This->driver_caps.user_cbufs) {
+if (!This->driver_caps.user_cbufs)
  This->constbuf_alignment = GET_PCAP(CONSTANT_BUFFER_OFFSET_ALIGNMENT);
-This->constbuf_uploader = u_upload_create(This->context.pipe, 
This->vs_const_size,
-  PIPE_BIND_CONSTANT_BUFFER, 
PIPE_USAGE_STREAM);
-}
-
-This->constbuf_sw_uploader = u_upload_create(This->pipe_sw, 128 * 1024,
- PIPE_BIND_CONSTANT_BUFFER, 
PIPE_USAGE_STREAM);
-
  This->driver_caps.window_space_position_support = 
GET_PCAP(TGSI_VS_WINDOW_SPACE_POSITION);
  This->driver_caps.vs_integer = pScreen->get_shader_param(pScreen, 
PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_INTEGERS);
  This->driver_caps.ps_integer = pScreen->get_shader_param(pScreen, 
PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_INTEGERS);
@@ -552,17 +529,6 @@ NineDevice9_dtor( struct NineDevice9 *This )
  nine_state_clear(>state, TRUE);
  nine_context_clear(This);
  
-if (This->vertex_uploader)

-u_upload_destroy(This->vertex_uploader);
-if (This->index_uploader)
-u_upload_destroy(This->index_uploader);
-if (This->constbuf_uploader)
-u_upload_destroy(This->constbuf_uploader);
-if (This->vertex_sw_uploader)
-u_upload_destroy(This->vertex_sw_uploader);
-if (This->constbuf_sw_uploader)
-u_upload_destroy(This->constbuf_sw_uploader);
-
  nine_bind(>record, NULL);
  
  pipe_sampler_view_reference(>dummy_sampler_view, NULL);

@@ -2853,14 +2819,14 @@ NineDevice9_DrawPrimitiveUP( struct NineDevice9 *This,
  vtxbuf.user_buffer = pVertexStreamZeroData;
  
  if (!This->driver_caps.user_vbufs) {

-u_upload_data(This->vertex_uploader,
+u_upload_data(This->context.pipe->stream_uploader,
0,
(prim_count_to_vertex_count(PrimitiveType, 
PrimitiveCount)) * VertexStreamZeroStride, /* XXX */
4,
vtxbuf.user_buffer,
_offset,
);
-u_upload_unmap(This->vertex_uploader);
+u_upload_unmap(This->context.pipe->stream_uploader);
  vtxbuf.user_buffer = NULL;
  }
  
@@ -2916,27 +2882,27 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This,
  
  if (!This->driver_caps.user_vbufs) {

  const unsigned base = MinVertexIndex *