st/nine: Refactor DrawPrimitiveUp
. Use the same fonction as DrawPrimitive . Drop the user vbuf path . Avoid setting NULL vertexbuffer to the context Signed-off-by: Axel Davy <davyaxel0@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9451>
This commit is contained in:
parent
247d135f67
commit
9168a37692
|
@ -512,7 +512,6 @@ NineDevice9_ctor( struct NineDevice9 *This,
|
|||
|
||||
/* Allocate upload helper for drivers that suck (from st pov ;). */
|
||||
|
||||
This->driver_caps.user_vbufs = GET_PCAP(USER_VERTEX_BUFFERS) && !This->csmt_active;
|
||||
This->driver_caps.user_sw_vbufs = This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_VERTEX_BUFFERS);
|
||||
This->vertex_uploader = This->csmt_active ? This->pipe_secondary->stream_uploader : This->context.pipe->stream_uploader;
|
||||
This->driver_caps.window_space_position_support = GET_PCAP(TGSI_VS_WINDOW_SPACE_POSITION);
|
||||
|
@ -2955,6 +2954,9 @@ NineDevice9_DrawIndexedPrimitive( struct NineDevice9 *This,
|
|||
return D3D_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
NineDevice9_SetStreamSourceNULL( struct NineDevice9 *This );
|
||||
|
||||
HRESULT NINE_WINAPI
|
||||
NineDevice9_DrawPrimitiveUP( struct NineDevice9 *This,
|
||||
D3DPRIMITIVETYPE PrimitiveType,
|
||||
|
@ -2962,7 +2964,8 @@ NineDevice9_DrawPrimitiveUP( struct NineDevice9 *This,
|
|||
const void *pVertexStreamZeroData,
|
||||
UINT VertexStreamZeroStride )
|
||||
{
|
||||
struct pipe_vertex_buffer vtxbuf;
|
||||
struct pipe_resource *resource = NULL;
|
||||
unsigned buffer_offset;
|
||||
|
||||
DBG("iface %p, PrimitiveType %u, PrimitiveCount %u, data %p, stride %u\n",
|
||||
This, PrimitiveType, PrimitiveCount,
|
||||
|
@ -2972,32 +2975,25 @@ NineDevice9_DrawPrimitiveUP( struct NineDevice9 *This,
|
|||
D3DERR_INVALIDCALL);
|
||||
user_assert(PrimitiveCount, D3D_OK);
|
||||
|
||||
vtxbuf.stride = VertexStreamZeroStride;
|
||||
vtxbuf.buffer_offset = 0;
|
||||
vtxbuf.is_user_buffer = true;
|
||||
vtxbuf.buffer.user = pVertexStreamZeroData;
|
||||
u_upload_data(This->vertex_uploader,
|
||||
0,
|
||||
(prim_count_to_vertex_count(PrimitiveType, PrimitiveCount)) * VertexStreamZeroStride,
|
||||
64,
|
||||
pVertexStreamZeroData,
|
||||
&buffer_offset,
|
||||
&resource);
|
||||
u_upload_unmap(This->vertex_uploader);
|
||||
|
||||
if (!This->driver_caps.user_vbufs) {
|
||||
vtxbuf.is_user_buffer = false;
|
||||
vtxbuf.buffer.resource = NULL;
|
||||
u_upload_data(This->vertex_uploader,
|
||||
0,
|
||||
(prim_count_to_vertex_count(PrimitiveType, PrimitiveCount)) * VertexStreamZeroStride, /* XXX */
|
||||
4,
|
||||
pVertexStreamZeroData,
|
||||
&vtxbuf.buffer_offset,
|
||||
&vtxbuf.buffer.resource);
|
||||
u_upload_unmap(This->vertex_uploader);
|
||||
}
|
||||
nine_context_set_stream_source_apply(This, 0, resource,
|
||||
buffer_offset, VertexStreamZeroStride);
|
||||
pipe_resource_reference(&resource, NULL);
|
||||
|
||||
NineBeforeDraw(This);
|
||||
nine_context_draw_primitive_from_vtxbuf(This, PrimitiveType, PrimitiveCount, &vtxbuf);
|
||||
nine_context_draw_primitive(This, PrimitiveType, 0, PrimitiveCount);
|
||||
NineAfterDraw(This);
|
||||
|
||||
pipe_vertex_buffer_unreference(&vtxbuf);
|
||||
|
||||
NineDevice9_PauseRecording(This);
|
||||
NineDevice9_SetStreamSource(This, 0, NULL, 0, 0);
|
||||
NineDevice9_SetStreamSourceNULL(This);
|
||||
NineDevice9_ResumeRecording(This);
|
||||
|
||||
return D3D_OK;
|
||||
|
@ -3015,6 +3011,9 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This,
|
|||
UINT VertexStreamZeroStride )
|
||||
{
|
||||
struct pipe_vertex_buffer vbuf;
|
||||
unsigned index_size = (IndexDataFormat == D3DFMT_INDEX16) ? 2 : 4;
|
||||
struct pipe_resource *ibuf = NULL;
|
||||
unsigned base;
|
||||
|
||||
DBG("iface %p, PrimitiveType %u, MinVertexIndex %u, NumVertices %u "
|
||||
"PrimitiveCount %u, pIndexData %p, IndexDataFormat %u "
|
||||
|
@ -3029,41 +3028,30 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This,
|
|||
IndexDataFormat == D3DFMT_INDEX32, D3DERR_INVALIDCALL);
|
||||
user_assert(PrimitiveCount, D3D_OK);
|
||||
|
||||
base = MinVertexIndex * VertexStreamZeroStride;
|
||||
vbuf.is_user_buffer = false;
|
||||
vbuf.buffer.resource = NULL;
|
||||
vbuf.stride = VertexStreamZeroStride;
|
||||
vbuf.buffer_offset = 0;
|
||||
vbuf.is_user_buffer = true;
|
||||
vbuf.buffer.user = pVertexStreamZeroData;
|
||||
|
||||
unsigned index_size = (IndexDataFormat == D3DFMT_INDEX16) ? 2 : 4;
|
||||
struct pipe_resource *ibuf = NULL;
|
||||
|
||||
if (!This->driver_caps.user_vbufs) {
|
||||
const unsigned base = MinVertexIndex * VertexStreamZeroStride;
|
||||
vbuf.is_user_buffer = false;
|
||||
vbuf.buffer.resource = NULL;
|
||||
u_upload_data(This->vertex_uploader,
|
||||
base,
|
||||
NumVertices * VertexStreamZeroStride, /* XXX */
|
||||
4,
|
||||
(const uint8_t *)pVertexStreamZeroData + base,
|
||||
&vbuf.buffer_offset,
|
||||
&vbuf.buffer.resource);
|
||||
u_upload_unmap(This->vertex_uploader);
|
||||
/* Won't be used: */
|
||||
vbuf.buffer_offset -= base;
|
||||
}
|
||||
u_upload_data(This->vertex_uploader,
|
||||
base,
|
||||
NumVertices * VertexStreamZeroStride, /* XXX */
|
||||
64,
|
||||
(const uint8_t *)pVertexStreamZeroData + base,
|
||||
&vbuf.buffer_offset,
|
||||
&vbuf.buffer.resource);
|
||||
u_upload_unmap(This->vertex_uploader);
|
||||
/* Won't be used: */
|
||||
vbuf.buffer_offset -= base;
|
||||
|
||||
unsigned index_offset = 0;
|
||||
if (This->csmt_active) {
|
||||
u_upload_data(This->pipe_secondary->stream_uploader,
|
||||
0,
|
||||
(prim_count_to_vertex_count(PrimitiveType, PrimitiveCount)) * index_size,
|
||||
4,
|
||||
pIndexData,
|
||||
&index_offset,
|
||||
&ibuf);
|
||||
u_upload_unmap(This->pipe_secondary->stream_uploader);
|
||||
}
|
||||
u_upload_data(This->pipe_secondary->stream_uploader,
|
||||
0,
|
||||
(prim_count_to_vertex_count(PrimitiveType, PrimitiveCount)) * index_size,
|
||||
64,
|
||||
pIndexData,
|
||||
&index_offset,
|
||||
&ibuf);
|
||||
u_upload_unmap(This->pipe_secondary->stream_uploader);
|
||||
|
||||
NineBeforeDraw(This);
|
||||
nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf(This, PrimitiveType,
|
||||
|
@ -3082,7 +3070,7 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This,
|
|||
|
||||
NineDevice9_PauseRecording(This);
|
||||
NineDevice9_SetIndices(This, NULL);
|
||||
NineDevice9_SetStreamSource(This, 0, NULL, 0, 0);
|
||||
NineDevice9_SetStreamSourceNULL(This);
|
||||
NineDevice9_ResumeRecording(This);
|
||||
|
||||
return D3D_OK;
|
||||
|
@ -3629,6 +3617,24 @@ NineDevice9_SetStreamSource( struct NineDevice9 *This,
|
|||
return D3D_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
NineDevice9_SetStreamSourceNULL( struct NineDevice9 *This )
|
||||
{
|
||||
struct nine_state *state = This->update;
|
||||
|
||||
DBG("This=%p\n", This);
|
||||
|
||||
state->vtxbuf[0].stride = 0;
|
||||
state->vtxbuf[0].buffer_offset = 0;
|
||||
|
||||
if (!state->stream[0])
|
||||
return;
|
||||
|
||||
NineBindBufferToDevice(This,
|
||||
(struct NineBuffer9 **)&state->stream[0],
|
||||
NULL);
|
||||
}
|
||||
|
||||
HRESULT NINE_WINAPI
|
||||
NineDevice9_GetStreamSource( struct NineDevice9 *This,
|
||||
UINT StreamNumber,
|
||||
|
|
|
@ -128,7 +128,6 @@ struct NineDevice9
|
|||
} cursor;
|
||||
|
||||
struct {
|
||||
boolean user_vbufs;
|
||||
boolean user_sw_vbufs;
|
||||
boolean window_space_position_support;
|
||||
boolean vs_integer;
|
||||
|
|
|
@ -1390,12 +1390,6 @@ nine_context_set_texture_apply(struct NineDevice9 *device,
|
|||
struct pipe_resource *res,
|
||||
struct pipe_sampler_view *view0,
|
||||
struct pipe_sampler_view *view1);
|
||||
static void
|
||||
nine_context_set_stream_source_apply(struct NineDevice9 *device,
|
||||
UINT StreamNumber,
|
||||
struct pipe_resource *res,
|
||||
UINT OffsetInBytes,
|
||||
UINT Stride);
|
||||
|
||||
static void
|
||||
nine_context_set_indices_apply(struct NineDevice9 *device,
|
||||
|
@ -2410,30 +2404,6 @@ CSMT_ITEM_NO_WAIT(nine_context_draw_indexed_primitive,
|
|||
context->pipe->draw_vbo(context->pipe, &info, NULL, &draw, 1);
|
||||
}
|
||||
|
||||
CSMT_ITEM_NO_WAIT(nine_context_draw_primitive_from_vtxbuf,
|
||||
ARG_VAL(D3DPRIMITIVETYPE, PrimitiveType),
|
||||
ARG_VAL(UINT, PrimitiveCount),
|
||||
ARG_BIND_VBUF(struct pipe_vertex_buffer, vtxbuf))
|
||||
{
|
||||
struct nine_context *context = &device->context;
|
||||
struct pipe_draw_info info;
|
||||
struct pipe_draw_start_count draw;
|
||||
|
||||
nine_update_state(device);
|
||||
|
||||
init_draw_info(&info, &draw, device, PrimitiveType, PrimitiveCount);
|
||||
info.index_size = 0;
|
||||
draw.start = 0;
|
||||
info.index_bias = 0;
|
||||
info.min_index = 0;
|
||||
info.max_index = draw.count - 1;
|
||||
info.index.resource = NULL;
|
||||
|
||||
context->pipe->set_vertex_buffers(context->pipe, 0, 1, 0, false, vtxbuf);
|
||||
|
||||
context->pipe->draw_vbo(context->pipe, &info, NULL, &draw, 1);
|
||||
}
|
||||
|
||||
CSMT_ITEM_NO_WAIT(nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf,
|
||||
ARG_VAL(D3DPRIMITIVETYPE, PrimitiveType),
|
||||
ARG_VAL(UINT, MinVertexIndex),
|
||||
|
@ -2465,6 +2435,7 @@ CSMT_ITEM_NO_WAIT(nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf,
|
|||
info.index.user = user_ibuf;
|
||||
|
||||
context->pipe->set_vertex_buffers(context->pipe, 0, 1, 0, false, vbuf);
|
||||
context->changed.vtxbuf |= 1;
|
||||
|
||||
context->pipe->draw_vbo(context->pipe, &info, NULL, &draw, 1);
|
||||
}
|
||||
|
|
|
@ -353,6 +353,13 @@ struct NineDevice9;
|
|||
* will append work to a worker thread when possible. Only the worker
|
||||
* thread can access struct nine_context. */
|
||||
|
||||
void
|
||||
nine_context_set_stream_source_apply(struct NineDevice9 *device,
|
||||
UINT StreamNumber,
|
||||
struct pipe_resource *res,
|
||||
UINT OffsetInBytes,
|
||||
UINT Stride);
|
||||
|
||||
void
|
||||
nine_context_set_render_state(struct NineDevice9 *device,
|
||||
D3DRENDERSTATETYPE State,
|
||||
|
@ -514,12 +521,6 @@ nine_context_draw_indexed_primitive(struct NineDevice9 *device,
|
|||
UINT StartIndex,
|
||||
UINT PrimitiveCount);
|
||||
|
||||
void
|
||||
nine_context_draw_primitive_from_vtxbuf(struct NineDevice9 *device,
|
||||
D3DPRIMITIVETYPE PrimitiveType,
|
||||
UINT PrimitiveCount,
|
||||
struct pipe_vertex_buffer *vtxbuf);
|
||||
|
||||
void
|
||||
nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf(struct NineDevice9 *device,
|
||||
D3DPRIMITIVETYPE PrimitiveType,
|
||||
|
|
Loading…
Reference in New Issue