Commit 040452ad authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Update the stream info before applying states.

parent 31d51fb1
......@@ -2215,6 +2215,8 @@ static void context_apply_state(struct wined3d_context *context, IWineD3DDeviceI
IWineD3DDeviceImpl_FindTexUnitMap(device);
device_preload_textures(device);
if (isStateDirty(context, STATE_VDECL))
device_update_stream_info(device, context->gl_info);
ENTER_GL();
for (i = 0; i < context->numDirtyEntries; ++i)
......
......@@ -332,7 +332,7 @@ static void stream_info_element_from_strided(const struct wined3d_gl_info *gl_in
e->buffer_object = 0;
}
void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info,
static void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info,
const struct WineDirect3DVertexStridedData *strided, struct wined3d_stream_info *stream_info)
{
unsigned int i;
......@@ -370,6 +370,76 @@ void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info,
}
}
static void device_trace_strided_stream_info(const struct wined3d_stream_info *stream_info)
{
TRACE("Strided Data:\n");
TRACE_STRIDED(stream_info, WINED3D_FFP_POSITION);
TRACE_STRIDED(stream_info, WINED3D_FFP_BLENDWEIGHT);
TRACE_STRIDED(stream_info, WINED3D_FFP_BLENDINDICES);
TRACE_STRIDED(stream_info, WINED3D_FFP_NORMAL);
TRACE_STRIDED(stream_info, WINED3D_FFP_PSIZE);
TRACE_STRIDED(stream_info, WINED3D_FFP_DIFFUSE);
TRACE_STRIDED(stream_info, WINED3D_FFP_SPECULAR);
TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD0);
TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD1);
TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD2);
TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD3);
TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD4);
TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD5);
TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD6);
TRACE_STRIDED(stream_info, WINED3D_FFP_TEXCOORD7);
}
/* Context activation is done by the caller. */
void device_update_stream_info(IWineD3DDeviceImpl *device, const struct wined3d_gl_info *gl_info)
{
struct wined3d_stream_info *stream_info = &device->strided_streams;
IWineD3DStateBlockImpl *stateblock = device->stateBlock;
BOOL vs = stateblock->vertexShader && device->vs_selected_mode != SHADER_NONE;
BOOL fixup = FALSE;
if (device->up_strided)
{
/* Note: this is a ddraw fixed-function code path. */
TRACE("=============================== Strided Input ================================\n");
device_stream_info_from_strided(gl_info, device->up_strided, stream_info);
if (TRACE_ON(d3d)) device_trace_strided_stream_info(stream_info);
}
else
{
TRACE("============================= Vertex Declaration =============================\n");
device_stream_info_from_declaration(device, vs, stream_info, &fixup);
}
if (vs && !stream_info->position_transformed)
{
if (((IWineD3DVertexDeclarationImpl *)stateblock->vertexDecl)->half_float_conv_needed && !fixup)
{
TRACE("Using drawStridedSlow with vertex shaders for FLOAT16 conversion.\n");
device->useDrawStridedSlow = TRUE;
}
else
{
device->useDrawStridedSlow = FALSE;
}
}
else
{
WORD slow_mask = (1 << WINED3D_FFP_PSIZE);
slow_mask |= -!gl_info->supported[ARB_VERTEX_ARRAY_BGRA]
& ((1 << WINED3D_FFP_DIFFUSE) | (1 << WINED3D_FFP_SPECULAR));
if ((stream_info->position_transformed || (stream_info->use_map & slow_mask)) && !fixup)
{
device->useDrawStridedSlow = TRUE;
}
else
{
device->useDrawStridedSlow = FALSE;
}
}
}
static void device_preload_texture(IWineD3DStateBlockImpl *stateblock, unsigned int idx)
{
IWineD3DBaseTextureImpl *texture;
......
......@@ -4438,87 +4438,11 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB
loadTexCoords(context, stateblock, si, &curVBO);
}
static inline void drawPrimitiveTraceDataLocations(const struct wined3d_stream_info *dataLocations)
{
/* Dump out what parts we have supplied */
TRACE("Strided Data:\n");
TRACE_STRIDED((dataLocations), WINED3D_FFP_POSITION);
TRACE_STRIDED((dataLocations), WINED3D_FFP_BLENDWEIGHT);
TRACE_STRIDED((dataLocations), WINED3D_FFP_BLENDINDICES);
TRACE_STRIDED((dataLocations), WINED3D_FFP_NORMAL);
TRACE_STRIDED((dataLocations), WINED3D_FFP_PSIZE);
TRACE_STRIDED((dataLocations), WINED3D_FFP_DIFFUSE);
TRACE_STRIDED((dataLocations), WINED3D_FFP_SPECULAR);
TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD0);
TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD1);
TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD2);
TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD3);
TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD4);
TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD5);
TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD6);
TRACE_STRIDED((dataLocations), WINED3D_FFP_TEXCOORD7);
}
static void streamsrc(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
IWineD3DDeviceImpl *device = stateblock->device;
BOOL fixup = FALSE;
struct wined3d_stream_info *dataLocations = &device->strided_streams;
BOOL useVertexShaderFunction;
BOOL load_numbered = FALSE;
BOOL load_named = FALSE;
useVertexShaderFunction = (device->vs_selected_mode != SHADER_NONE && stateblock->vertexShader) ? TRUE : FALSE;
if(device->up_strided) {
/* Note: this is a ddraw fixed-function code path */
TRACE("================ Strided Input ===================\n");
device_stream_info_from_strided(gl_info, device->up_strided, dataLocations);
if(TRACE_ON(d3d)) {
drawPrimitiveTraceDataLocations(dataLocations);
}
} else {
/* Note: This is a fixed function or shader codepath.
* This means it must handle both types of strided data.
* Shaders must go through here to zero the strided data, even if they
* don't set any declaration at all
*/
TRACE("================ Vertex Declaration ===================\n");
device_stream_info_from_declaration(device, useVertexShaderFunction, dataLocations, &fixup);
}
if (dataLocations->position_transformed) useVertexShaderFunction = FALSE;
if(useVertexShaderFunction) {
if(((IWineD3DVertexDeclarationImpl *) stateblock->vertexDecl)->half_float_conv_needed && !fixup) {
TRACE("Using drawStridedSlow with vertex shaders for FLOAT16 conversion\n");
device->useDrawStridedSlow = TRUE;
} else {
load_numbered = TRUE;
device->useDrawStridedSlow = FALSE;
}
}
else
{
WORD slow_mask = (1 << WINED3D_FFP_PSIZE);
slow_mask |= -!gl_info->supported[ARB_VERTEX_ARRAY_BGRA]
& ((1 << WINED3D_FFP_DIFFUSE) | (1 << WINED3D_FFP_SPECULAR));
if (fixup || (!dataLocations->position_transformed
&& !(dataLocations->use_map & slow_mask)))
{
/* Load the vertex data using named arrays */
load_named = TRUE;
device->useDrawStridedSlow = FALSE;
}
else
{
TRACE("Not loading vertex data\n");
device->useDrawStridedSlow = TRUE;
}
}
BOOL load_numbered = use_vs(stateblock) && !device->useDrawStridedSlow;
BOOL load_named = !use_vs(stateblock) && !device->useDrawStridedSlow;
if (context->numberedArraysLoaded && !load_numbered)
{
......@@ -4535,13 +4459,13 @@ static void streamsrc(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wi
if (load_numbered)
{
TRACE("Loading numbered arrays\n");
loadNumberedArrays(stateblock, dataLocations, context);
loadNumberedArrays(stateblock, &device->strided_streams, context);
context->numberedArraysLoaded = TRUE;
}
else if (load_named)
{
TRACE("Loading vertex data\n");
loadVertexData(context, stateblock, dataLocations);
loadVertexData(context, stateblock, &device->strided_streams);
context->namedArraysLoaded = TRUE;
}
}
......
......@@ -1627,8 +1627,7 @@ void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource) D
void device_resource_released(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN;
void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup) DECLSPEC_HIDDEN;
void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info,
const struct WineDirect3DVertexStridedData *strided, struct wined3d_stream_info *stream_info) DECLSPEC_HIDDEN;
void device_update_stream_info(IWineD3DDeviceImpl *device, const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, DWORD Count,
const WINED3DRECT *pRects, DWORD Flags, WINED3DCOLOR Color, float Z, DWORD Stencil) DECLSPEC_HIDDEN;
void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment