wined3d: Get rid of the use_vshader parameter to device_stream_info_from_declaration().

This commit is contained in:
Henri Verbeet 2011-07-26 19:52:43 +02:00 committed by Alexandre Julliard
parent bd1429e248
commit 26cd7b835d
3 changed files with 27 additions and 17 deletions

View File

@ -172,11 +172,12 @@ static BOOL fixed_get_input(BYTE usage, BYTE usage_idx, unsigned int *regnum)
/* Context activation is done by the caller. */ /* Context activation is done by the caller. */
void device_stream_info_from_declaration(struct wined3d_device *device, void device_stream_info_from_declaration(struct wined3d_device *device,
BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup) struct wined3d_stream_info *stream_info, BOOL *fixup)
{ {
const struct wined3d_state *state = &device->stateBlock->state; const struct wined3d_state *state = &device->stateBlock->state;
/* We need to deal with frequency data! */ /* We need to deal with frequency data! */
struct wined3d_vertex_declaration *declaration = state->vertex_declaration; struct wined3d_vertex_declaration *declaration = state->vertex_declaration;
BOOL use_vshader;
unsigned int i; unsigned int i;
stream_info->use_map = 0; stream_info->use_map = 0;
@ -184,7 +185,7 @@ void device_stream_info_from_declaration(struct wined3d_device *device,
/* Check for transformed vertices, disable vertex shader if present. */ /* Check for transformed vertices, disable vertex shader if present. */
stream_info->position_transformed = declaration->position_transformed; stream_info->position_transformed = declaration->position_transformed;
if (declaration->position_transformed) use_vshader = FALSE; use_vshader = state->vertex_shader && !declaration->position_transformed;
/* Translate the declaration into strided data. */ /* Translate the declaration into strided data. */
for (i = 0; i < declaration->element_count; ++i) for (i = 0; i < declaration->element_count; ++i)
@ -426,7 +427,7 @@ void device_update_stream_info(struct wined3d_device *device, const struct wined
else else
{ {
TRACE("============================= Vertex Declaration =============================\n"); TRACE("============================= Vertex Declaration =============================\n");
device_stream_info_from_declaration(device, !!state->vertex_shader, stream_info, &fixup); device_stream_info_from_declaration(device, stream_info, &fixup);
} }
if (state->vertex_shader && !stream_info->position_transformed) if (state->vertex_shader && !stream_info->position_transformed)
@ -3517,10 +3518,12 @@ HRESULT CDECL wined3d_device_process_vertices(struct wined3d_device *device,
UINT src_start_idx, UINT dst_idx, UINT vertex_count, struct wined3d_buffer *dst_buffer, UINT src_start_idx, UINT dst_idx, UINT vertex_count, struct wined3d_buffer *dst_buffer,
struct wined3d_vertex_declaration *declaration, DWORD flags, DWORD dst_fvf) struct wined3d_vertex_declaration *declaration, DWORD flags, DWORD dst_fvf)
{ {
BOOL vbo = FALSE, streamWasUP = device->stateBlock->state.user_stream; struct wined3d_state *state = &device->stateBlock->state;
BOOL vbo = FALSE, streamWasUP = state->user_stream;
struct wined3d_stream_info stream_info; struct wined3d_stream_info stream_info;
const struct wined3d_gl_info *gl_info; const struct wined3d_gl_info *gl_info;
struct wined3d_context *context; struct wined3d_context *context;
struct wined3d_shader *vs;
HRESULT hr; HRESULT hr;
TRACE("device %p, src_start_idx %u, dst_idx %u, vertex_count %u, " TRACE("device %p, src_start_idx %u, dst_idx %u, vertex_count %u, "
@ -3535,12 +3538,15 @@ HRESULT CDECL wined3d_device_process_vertices(struct wined3d_device *device,
context = context_acquire(device, NULL); context = context_acquire(device, NULL);
gl_info = context->gl_info; gl_info = context->gl_info;
/* ProcessVertices reads from vertex buffers, which have to be assigned. DrawPrimitive and DrawPrimitiveUP /* ProcessVertices reads from vertex buffers, which have to be assigned.
* control the streamIsUP flag, thus restore it afterwards. * DrawPrimitive and DrawPrimitiveUP control the streamIsUP flag, thus
*/ * restore it afterwards. */
device->stateBlock->state.user_stream = FALSE; vs = state->vertex_shader;
device_stream_info_from_declaration(device, FALSE, &stream_info, &vbo); state->vertex_shader = NULL;
device->stateBlock->state.user_stream = streamWasUP; state->user_stream = FALSE;
device_stream_info_from_declaration(device, &stream_info, &vbo);
state->user_stream = streamWasUP;
state->vertex_shader = vs;
if (vbo || src_start_idx) if (vbo || src_start_idx)
{ {
@ -3559,7 +3565,7 @@ HRESULT CDECL wined3d_device_process_vertices(struct wined3d_device *device,
e = &stream_info.elements[i]; e = &stream_info.elements[i];
if (e->data.buffer_object) if (e->data.buffer_object)
{ {
struct wined3d_buffer *vb = device->stateBlock->state.streams[e->stream_idx].buffer; struct wined3d_buffer *vb = state->streams[e->stream_idx].buffer;
e->data.buffer_object = 0; e->data.buffer_object = 0;
e->data.addr = (BYTE *)((ULONG_PTR)e->data.addr + (ULONG_PTR)buffer_get_sysmem(vb, gl_info)); e->data.addr = (BYTE *)((ULONG_PTR)e->data.addr + (ULONG_PTR)buffer_get_sysmem(vb, gl_info));
ENTER_GL(); ENTER_GL();

View File

@ -790,9 +790,11 @@ HRESULT tesselate_rectpatch(struct wined3d_device *This, struct WineD3DRectPatch
{ {
unsigned int i, j, num_quads, out_vertex_size, buffer_size, d3d_out_vertex_size; unsigned int i, j, num_quads, out_vertex_size, buffer_size, d3d_out_vertex_size;
float max_x = 0.0f, max_y = 0.0f, max_z = 0.0f, neg_z = 0.0f; float max_x = 0.0f, max_y = 0.0f, max_z = 0.0f, neg_z = 0.0f;
struct wined3d_state *state = &This->stateBlock->state;
struct wined3d_stream_info stream_info; struct wined3d_stream_info stream_info;
struct wined3d_stream_info_element *e; struct wined3d_stream_info_element *e;
struct wined3d_context *context; struct wined3d_context *context;
struct wined3d_shader *vs;
const BYTE *data; const BYTE *data;
const WINED3DRECTPATCH_INFO *info = &patch->RectPatchInfo; const WINED3DRECTPATCH_INFO *info = &patch->RectPatchInfo;
DWORD vtxStride; DWORD vtxStride;
@ -805,15 +807,17 @@ HRESULT tesselate_rectpatch(struct wined3d_device *This, struct WineD3DRectPatch
context = context_acquire(This, NULL); context = context_acquire(This, NULL);
context_apply_blit_state(context, This); context_apply_blit_state(context, This);
/* First, locate the position data. This is provided in a vertex buffer in the stateblock. /* First, locate the position data. This is provided in a vertex buffer in
* Beware of vbos * the stateblock. Beware of VBOs. */
*/ vs = state->vertex_shader;
device_stream_info_from_declaration(This, FALSE, &stream_info, NULL); state->vertex_shader = NULL;
device_stream_info_from_declaration(This, &stream_info, NULL);
state->vertex_shader = vs;
e = &stream_info.elements[WINED3D_FFP_POSITION]; e = &stream_info.elements[WINED3D_FFP_POSITION];
if (e->data.buffer_object) if (e->data.buffer_object)
{ {
struct wined3d_buffer *vb = This->stateBlock->state.streams[e->stream_idx].buffer; struct wined3d_buffer *vb = state->streams[e->stream_idx].buffer;
e->data.addr = (BYTE *)((ULONG_PTR)e->data.addr + (ULONG_PTR)buffer_get_sysmem(vb, context->gl_info)); e->data.addr = (BYTE *)((ULONG_PTR)e->data.addr + (ULONG_PTR)buffer_get_sysmem(vb, context->gl_info));
} }
vtxStride = e->stride; vtxStride = e->stride;

View File

@ -1759,7 +1759,7 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL
void device_resource_add(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN; void device_resource_add(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN; void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void device_stream_info_from_declaration(struct wined3d_device *device, void device_stream_info_from_declaration(struct wined3d_device *device,
BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup) DECLSPEC_HIDDEN; struct wined3d_stream_info *stream_info, BOOL *fixup) DECLSPEC_HIDDEN;
void device_switch_onscreen_ds(struct wined3d_device *device, struct wined3d_context *context, void device_switch_onscreen_ds(struct wined3d_device *device, struct wined3d_context *context,
struct wined3d_surface *depth_stencil) DECLSPEC_HIDDEN; struct wined3d_surface *depth_stencil) DECLSPEC_HIDDEN;
void device_update_stream_info(struct wined3d_device *device, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN; void device_update_stream_info(struct wined3d_device *device, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;