/***************************************************************************** * IDirect3DVertexBuffer7::ProcessVertices * * Processes untransformed Vertices into a transformed or optimized vertex * buffer. It can also perform other operations, such as lighting or clipping * * Params * VertexOp: Operation(s) to perform: D3DVOP_CLIP, _EXTENTS, _LIGHT, _TRANSFORM * DestIndex: Index in the destination buffer(This), where the vertices are * placed * Count: Number of Vertices in the Source buffer to process * SrcBuffer: Source vertex buffer * SrcIndex: Index of the first vertex in the src buffer to process * D3DDevice: Device to use for transformation * Flags: 0 for default, D3DPV_DONOTCOPYDATA to prevent copying * unchaned vertices * * Returns: * D3D_OK on success * DDERR_INVALIDPARAMS If D3DVOP_TRANSFORM wasn't passed * *****************************************************************************/ static HRESULT WINAPI IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexBuffer7 *iface, DWORD VertexOp, DWORD DestIndex, DWORD Count, IDirect3DVertexBuffer7 *SrcBuffer, DWORD SrcIndex, IDirect3DDevice7 *D3DDevice, DWORD Flags) { IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface; IDirect3DVertexBufferImpl *Src = (IDirect3DVertexBufferImpl *)SrcBuffer; IDirect3DDeviceImpl *D3D = (IDirect3DDeviceImpl *)D3DDevice; BOOL oldClip, doClip; HRESULT hr; TRACE("iface %p, vertex_op %#x, dst_idx %u, count %u, src_buffer %p, src_idx %u, device %p, flags %#x.\n", iface, VertexOp, DestIndex, Count, SrcBuffer, SrcIndex, D3DDevice, Flags); /* Vertex operations: * D3DVOP_CLIP: Clips vertices outside the viewing frustrum. Needs clipping information * in the vertex buffer (Buffer may not be created with D3DVBCAPS_DONOTCLIP) * D3DVOP_EXTENTS: Causes the screen extents to be updated when rendering the vertices * D3DVOP_LIGHT: Lights the vertices * D3DVOP_TRANSFORM: Transform the vertices. This flag is necessary * * WineD3D only transforms and clips the vertices by now, so EXTENTS and LIGHT * are not implemented. Clipping is disabled ATM, because of unsure conditions. */ if( !(VertexOp & D3DVOP_TRANSFORM) ) return DDERR_INVALIDPARAMS; EnterCriticalSection(&ddraw_cs); /* WineD3D doesn't know d3d7 vertex operation, it uses * render states instead. Set the render states according to * the vertex ops */ doClip = VertexOp & D3DVOP_CLIP ? TRUE : FALSE; wined3d_device_get_render_state(D3D->wined3d_device, WINED3DRS_CLIPPING, (DWORD *)&oldClip); if (doClip != oldClip) wined3d_device_set_render_state(D3D->wined3d_device, WINED3DRS_CLIPPING, doClip); wined3d_device_set_stream_source(D3D->wined3d_device, 0, Src->wineD3DVertexBuffer, 0, get_flexible_vertex_size(Src->fvf)); wined3d_device_set_vertex_declaration(D3D->wined3d_device, Src->wineD3DVertexDeclaration); hr = wined3d_device_process_vertices(D3D->wined3d_device, SrcIndex, DestIndex, Count, This->wineD3DVertexBuffer, NULL, Flags, This->fvf); /* Restore the states if needed */ if (doClip != oldClip) wined3d_device_set_render_state(D3D->wined3d_device, WINED3DRS_CLIPPING, oldClip); LeaveCriticalSection(&ddraw_cs); return hr; }
/***************************************************************************** * IDirect3DVertexBuffer7::ProcessVertices * * Processes untransformed Vertices into a transformed or optimized vertex * buffer. It can also perform other operations, such as lighting or clipping * * Params * VertexOp: Operation(s) to perform: D3DVOP_CLIP, _EXTENTS, _LIGHT, _TRANSFORM * DestIndex: Index in the destination buffer(This), where the vertices are * placed * Count: Number of Vertices in the Source buffer to process * SrcBuffer: Source vertex buffer * SrcIndex: Index of the first vertex in the src buffer to process * D3DDevice: Device to use for transformation * Flags: 0 for default, D3DPV_DONOTCOPYDATA to prevent copying * unchaned vertices * * Returns: * D3D_OK on success * DDERR_INVALIDPARAMS If D3DVOP_TRANSFORM wasn't passed * *****************************************************************************/ static HRESULT WINAPI d3d_vertex_buffer7_ProcessVertices(IDirect3DVertexBuffer7 *iface, DWORD vertex_op, DWORD dst_idx, DWORD count, IDirect3DVertexBuffer7 *src_buffer, DWORD src_idx, IDirect3DDevice7 *device, DWORD flags) { struct d3d_vertex_buffer *dst_buffer_impl = impl_from_IDirect3DVertexBuffer7(iface); struct d3d_vertex_buffer *src_buffer_impl = unsafe_impl_from_IDirect3DVertexBuffer7(src_buffer); struct d3d_device *device_impl = unsafe_impl_from_IDirect3DDevice7(device); BOOL oldClip, doClip; HRESULT hr; TRACE("iface %p, vertex_op %#x, dst_idx %u, count %u, src_buffer %p, src_idx %u, device %p, flags %#x.\n", iface, vertex_op, dst_idx, count, src_buffer, src_idx, device, flags); /* Vertex operations: * D3DVOP_CLIP: Clips vertices outside the viewing frustrum. Needs clipping information * in the vertex buffer (Buffer may not be created with D3DVBCAPS_DONOTCLIP) * D3DVOP_EXTENTS: Causes the screen extents to be updated when rendering the vertices * D3DVOP_LIGHT: Lights the vertices * D3DVOP_TRANSFORM: Transform the vertices. This flag is necessary * * WineD3D only transforms and clips the vertices by now, so EXTENTS and LIGHT * are not implemented. Clipping is disabled ATM, because of unsure conditions. */ if (!(vertex_op & D3DVOP_TRANSFORM)) return DDERR_INVALIDPARAMS; wined3d_mutex_lock(); /* WineD3D doesn't know d3d7 vertex operation, it uses * render states instead. Set the render states according to * the vertex ops */ doClip = !!(vertex_op & D3DVOP_CLIP); oldClip = wined3d_device_get_render_state(device_impl->wined3d_device, WINED3D_RS_CLIPPING); if (doClip != oldClip) wined3d_device_set_render_state(device_impl->wined3d_device, WINED3D_RS_CLIPPING, doClip); wined3d_device_set_stream_source(device_impl->wined3d_device, 0, src_buffer_impl->wineD3DVertexBuffer, 0, get_flexible_vertex_size(src_buffer_impl->fvf)); wined3d_device_set_vertex_declaration(device_impl->wined3d_device, src_buffer_impl->wineD3DVertexDeclaration); hr = wined3d_device_process_vertices(device_impl->wined3d_device, src_idx, dst_idx, count, dst_buffer_impl->wineD3DVertexBuffer, NULL, flags, dst_buffer_impl->fvf); /* Restore the states if needed */ if (doClip != oldClip) wined3d_device_set_render_state(device_impl->wined3d_device, WINED3D_RS_CLIPPING, oldClip); wined3d_mutex_unlock(); return hr; }