wined3d: Include the base vertex index in WINED3D_CS_OP_DRAW.

Ideally we'd just remove the base vertex index from the wined3d_state
structure, but it's included in d3d8 stateblocks.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2016-06-21 10:32:44 +02:00 committed by Alexandre Julliard
parent a1bc5b8c97
commit 9c1fbe5095
4 changed files with 34 additions and 31 deletions

View File

@ -78,10 +78,11 @@ struct wined3d_cs_clear
struct wined3d_cs_draw
{
enum wined3d_cs_op opcode;
UINT start_idx;
UINT index_count;
UINT start_instance;
UINT instance_count;
int base_vertex_idx;
unsigned int start_idx;
unsigned int index_count;
unsigned int start_instance;
unsigned int instance_count;
BOOL indexed;
};
@ -312,17 +313,18 @@ static void wined3d_cs_exec_draw(struct wined3d_cs *cs, const void *data)
{
const struct wined3d_cs_draw *op = data;
draw_primitive(cs->device, &cs->device->state, op->start_idx, op->index_count,
op->start_instance, op->instance_count, op->indexed);
draw_primitive(cs->device, &cs->device->state, op->base_vertex_idx, op->start_idx,
op->index_count, op->start_instance, op->instance_count, op->indexed);
}
void wined3d_cs_emit_draw(struct wined3d_cs *cs, UINT start_idx, UINT index_count,
UINT start_instance, UINT instance_count, BOOL indexed)
void wined3d_cs_emit_draw(struct wined3d_cs *cs, int base_vertex_idx, unsigned int start_idx,
unsigned int index_count, unsigned int start_instance, unsigned int instance_count, BOOL indexed)
{
struct wined3d_cs_draw *op;
op = cs->ops->require_space(cs, sizeof(*op));
op->opcode = WINED3D_CS_OP_DRAW;
op->base_vertex_idx = base_vertex_idx;
op->start_idx = start_idx;
op->index_count = index_count;
op->start_instance = start_instance;

View File

@ -3503,7 +3503,7 @@ HRESULT CDECL wined3d_device_draw_primitive(struct wined3d_device *device, UINT
device_invalidate_state(device, STATE_BASEVERTEXINDEX);
}
wined3d_cs_emit_draw(device->cs, start_vertex, vertex_count, 0, 0, FALSE);
wined3d_cs_emit_draw(device->cs, 0, start_vertex, vertex_count, 0, 0, FALSE);
return WINED3D_OK;
}
@ -3514,7 +3514,7 @@ void CDECL wined3d_device_draw_primitive_instanced(struct wined3d_device *device
TRACE("device %p, start_vertex %u, vertex_count %u, start_instance %u, instance_count %u.\n",
device, start_vertex, vertex_count, start_instance, instance_count);
wined3d_cs_emit_draw(device->cs, start_vertex, vertex_count, start_instance, instance_count, FALSE);
wined3d_cs_emit_draw(device->cs, 0, start_vertex, vertex_count, start_instance, instance_count, FALSE);
}
HRESULT CDECL wined3d_device_draw_indexed_primitive(struct wined3d_device *device, UINT start_idx, UINT index_count)
@ -3540,7 +3540,7 @@ HRESULT CDECL wined3d_device_draw_indexed_primitive(struct wined3d_device *devic
device_invalidate_state(device, STATE_BASEVERTEXINDEX);
}
wined3d_cs_emit_draw(device->cs, start_idx, index_count, 0, 0, TRUE);
wined3d_cs_emit_draw(device->cs, device->state.base_vertex_index, start_idx, index_count, 0, 0, TRUE);
return WINED3D_OK;
}
@ -3551,7 +3551,8 @@ void CDECL wined3d_device_draw_indexed_primitive_instanced(struct wined3d_device
TRACE("device %p, start_idx %u, index_count %u, start_instance %u, instance_count %u.\n",
device, start_idx, index_count, start_instance, instance_count);
wined3d_cs_emit_draw(device->cs, start_idx, index_count, start_instance, instance_count, TRUE);
wined3d_cs_emit_draw(device->cs, device->state.base_vertex_index,
start_idx, index_count, start_instance, instance_count, TRUE);
}
static HRESULT wined3d_device_update_texture_3d(struct wined3d_device *device,

View File

@ -38,8 +38,8 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d);
/* Context activation is done by the caller. */
static void draw_primitive_arrays(struct wined3d_context *context, const struct wined3d_state *state,
unsigned int count, const void *idx_data, unsigned int idx_size, unsigned int start_idx,
unsigned int start_instance, unsigned int instance_count)
const void *idx_data, unsigned int idx_size, int base_vertex_idx, unsigned int start_idx,
unsigned int count, unsigned int start_instance, unsigned int instance_count)
{
const struct wined3d_ffp_attrib_ops *ops = &context->d3d_info->ffp_attrib_ops;
GLenum idx_type = idx_size == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT;
@ -61,7 +61,7 @@ static void draw_primitive_arrays(struct wined3d_context *context, const struct
if (gl_info->supported[ARB_DRAW_ELEMENTS_BASE_VERTEX])
{
GL_EXTCALL(glDrawElementsBaseVertex(state->gl_primitive_type, count, idx_type,
(const char *)idx_data + (idx_size * start_idx), state->base_vertex_index));
(const char *)idx_data + (idx_size * start_idx), base_vertex_idx));
checkGLcall("glDrawElementsBaseVertex");
return;
}
@ -87,7 +87,7 @@ static void draw_primitive_arrays(struct wined3d_context *context, const struct
if (gl_info->supported[ARB_DRAW_ELEMENTS_BASE_VERTEX])
{
GL_EXTCALL(glDrawElementsInstancedBaseVertex(state->gl_primitive_type, count, idx_type,
(const char *)idx_data + (idx_size * start_idx), instance_count, state->base_vertex_index));
(const char *)idx_data + (idx_size * start_idx), instance_count, base_vertex_idx));
checkGLcall("glDrawElementsInstancedBaseVertex");
return;
}
@ -142,7 +142,7 @@ static void draw_primitive_arrays(struct wined3d_context *context, const struct
if (gl_info->supported[ARB_DRAW_ELEMENTS_BASE_VERTEX])
{
GL_EXTCALL(glDrawElementsBaseVertex(state->gl_primitive_type, count, idx_type,
(const char *)idx_data + (idx_size * start_idx), state->base_vertex_index));
(const char *)idx_data + (idx_size * start_idx), base_vertex_idx));
checkGLcall("glDrawElementsBaseVertex");
}
else
@ -166,8 +166,8 @@ static unsigned int get_stride_idx(const void *idx_data, unsigned int idx_size,
/* Context activation is done by the caller. */
static void draw_primitive_immediate_mode(struct wined3d_context *context, const struct wined3d_state *state,
const struct wined3d_stream_info *si, unsigned int vertex_count, const void *idx_data,
unsigned int idx_size, unsigned int start_idx, unsigned int instance_count)
const struct wined3d_stream_info *si, const void *idx_data, unsigned int idx_size,
int base_vertex_idx, unsigned int start_idx, unsigned int vertex_count, unsigned int instance_count)
{
const BYTE *position = NULL, *normal = NULL, *diffuse = NULL, *specular = NULL;
const struct wined3d_d3d_info *d3d_info = context->d3d_info;
@ -214,7 +214,7 @@ static void draw_primitive_immediate_mode(struct wined3d_context *context, const
unsigned int use_map = si->use_map;
unsigned int element_idx;
stride_idx = get_stride_idx(idx_data, idx_size, state->base_vertex_index, start_idx, vertex_idx);
stride_idx = get_stride_idx(idx_data, idx_size, base_vertex_idx, start_idx, vertex_idx);
for (element_idx = MAX_ATTRIBS - 1; use_map; use_map &= ~(1u << element_idx), --element_idx)
{
if (!(use_map & 1u << element_idx))
@ -328,7 +328,7 @@ static void draw_primitive_immediate_mode(struct wined3d_context *context, const
{
unsigned int tmp_tex_mask;
stride_idx = get_stride_idx(idx_data, idx_size, state->base_vertex_index, start_idx, vertex_idx);
stride_idx = get_stride_idx(idx_data, idx_size, base_vertex_idx, start_idx, vertex_idx);
if (normal)
{
@ -409,8 +409,8 @@ static void remove_vbos(struct wined3d_context *context,
/* Routine common to the draw primitive and draw indexed primitive routines */
void draw_primitive(struct wined3d_device *device, const struct wined3d_state *state,
unsigned int start_idx, unsigned int index_count, unsigned int start_instance,
unsigned int instance_count, BOOL indexed)
int base_vertex_idx, unsigned int start_idx, unsigned int index_count,
unsigned int start_instance, unsigned int instance_count, BOOL indexed)
{
const struct wined3d_fb_state *fb = state->fb;
const struct wined3d_stream_info *stream_info;
@ -574,11 +574,11 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s
}
if (context->use_immediate_mode_draw || emulation)
draw_primitive_immediate_mode(context, state, stream_info, index_count,
idx_data, idx_size, start_idx, instance_count);
draw_primitive_immediate_mode(context, state, stream_info, idx_data,
idx_size, base_vertex_idx, start_idx, index_count, instance_count);
else
draw_primitive_arrays(context, state, index_count, idx_data,
idx_size, start_idx, start_instance, instance_count);
draw_primitive_arrays(context, state, idx_data, idx_size, base_vertex_idx,
start_idx, index_count, start_instance, instance_count);
if (ib_query)
wined3d_event_query_issue(ib_query, device);

View File

@ -1225,8 +1225,8 @@ struct wined3d_stream_info
};
void draw_primitive(struct wined3d_device *device, const struct wined3d_state *state,
unsigned int start_idx, unsigned int index_count, unsigned int start_instance,
unsigned int instance_count, BOOL indexed) DECLSPEC_HIDDEN;
int base_vertex_idx, unsigned int start_idx, unsigned int index_count,
unsigned int start_instance, unsigned int instance_count, BOOL indexed) DECLSPEC_HIDDEN;
DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) DECLSPEC_HIDDEN;
#define eps 1e-8f
@ -2916,8 +2916,8 @@ void wined3d_cs_destroy(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT *rects,
DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
void wined3d_cs_emit_draw(struct wined3d_cs *cs, UINT start_idx, UINT index_count,
UINT start_instance, UINT instance_count, BOOL indexed) DECLSPEC_HIDDEN;
void wined3d_cs_emit_draw(struct wined3d_cs *cs, int base_vertex_idx, unsigned int start_idx, unsigned int index_count,
unsigned int start_instance, unsigned int instance_count, BOOL indexed) DECLSPEC_HIDDEN;
void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain,
const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, DWORD flags) DECLSPEC_HIDDEN;
void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) DECLSPEC_HIDDEN;