Commit e31ea51b authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Move the vertex declaration to wined3d_state.

parent d728d5f0
......@@ -467,7 +467,7 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This)
* analyse the strided streams in depth, just set them up for no conversion. Return decl changed
* if we used conversion before
*/
if (!((IWineD3DVertexDeclarationImpl *) device->stateBlock->vertexDecl)->half_float_conv_needed)
if (!device->stateBlock->state.vertex_declaration->half_float_conv_needed)
{
if (This->conversion_map)
{
......
......@@ -177,7 +177,7 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup)
{
/* We need to deal with frequency data! */
IWineD3DVertexDeclarationImpl *declaration = (IWineD3DVertexDeclarationImpl *)This->stateBlock->vertexDecl;
IWineD3DVertexDeclarationImpl *declaration = This->stateBlock->state.vertex_declaration;
unsigned int i;
stream_info->use_map = 0;
......@@ -426,7 +426,7 @@ void device_update_stream_info(IWineD3DDeviceImpl *device, const struct wined3d_
if (vs && !stream_info->position_transformed)
{
if (((IWineD3DVertexDeclarationImpl *)stateblock->vertexDecl)->half_float_conv_needed && !fixup)
if (stateblock->state.vertex_declaration->half_float_conv_needed && !fixup)
{
TRACE("Using drawStridedSlow with vertex shaders for FLOAT16 conversion.\n");
device->useDrawStridedSlow = TRUE;
......@@ -3164,14 +3164,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetScissorRect(IWineD3DDevice *iface, R
static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexDeclaration(IWineD3DDevice* iface, IWineD3DVertexDeclaration* pDecl) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
IWineD3DVertexDeclaration *oldDecl = This->updateStateBlock->vertexDecl;
IWineD3DVertexDeclaration *oldDecl = (IWineD3DVertexDeclaration *)This->updateStateBlock->state.vertex_declaration;
TRACE("(%p) : pDecl=%p\n", This, pDecl);
if (pDecl) IWineD3DVertexDeclaration_AddRef(pDecl);
if (oldDecl) IWineD3DVertexDeclaration_Release(oldDecl);
This->updateStateBlock->vertexDecl = pDecl;
This->updateStateBlock->state.vertex_declaration = (IWineD3DVertexDeclarationImpl *)pDecl;
This->updateStateBlock->changed.vertexDecl = TRUE;
if (This->isRecordingState) {
......@@ -3192,7 +3192,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetVertexDeclaration(IWineD3DDevice* if
TRACE("(%p) : ppDecl=%p\n", This, ppDecl);
*ppDecl = This->stateBlock->vertexDecl;
*ppDecl = (IWineD3DVertexDeclaration *)This->stateBlock->state.vertex_declaration;
if (*ppDecl) IWineD3DVertexDeclaration_AddRef(*ppDecl);
return WINED3D_OK;
}
......@@ -4671,7 +4671,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitive(IWineD3DDevice *iface, UI
TRACE("(%p) : start %u, count %u\n", This, StartVertex, vertex_count);
if(!This->stateBlock->vertexDecl) {
if (!This->stateBlock->state.vertex_declaration)
{
WARN("(%p) : Called without a valid vertex declaration set\n", This);
return WINED3DERR_INVALIDCALL;
}
......@@ -4709,7 +4710,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *if
return WINED3DERR_INVALIDCALL;
}
if(!This->stateBlock->vertexDecl) {
if (!This->stateBlock->state.vertex_declaration)
{
WARN("(%p) : Called without a valid vertex declaration set\n", This);
return WINED3DERR_INVALIDCALL;
}
......@@ -4749,7 +4751,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveUP(IWineD3DDevice *iface,
TRACE("(%p) : vertex count %u, pVtxData %p, stride %u\n",
This, vertex_count, pVertexStreamZeroData, VertexStreamZeroStride);
if(!This->stateBlock->vertexDecl) {
if (!This->stateBlock->state.vertex_declaration)
{
WARN("(%p) : Called without a valid vertex declaration set\n", This);
return WINED3DERR_INVALIDCALL;
}
......@@ -4792,7 +4795,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *
TRACE("(%p) : index count %u, pidxdata %p, IdxFmt %u, pVtxdata %p, stride=%u.\n",
This, index_count, pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
if(!This->stateBlock->vertexDecl) {
if (!This->stateBlock->state.vertex_declaration)
{
WARN("(%p) : Called without a valid vertex declaration set\n", This);
return WINED3DERR_INVALIDCALL;
}
......
......@@ -492,7 +492,8 @@ static ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) {
if (!refCount) {
int counter;
if (This->vertexDecl) IWineD3DVertexDeclaration_Release(This->vertexDecl);
if (This->state.vertex_declaration)
IWineD3DVertexDeclaration_Release((IWineD3DVertexDeclaration *)This->state.vertex_declaration);
for (counter = 0; counter < MAX_COMBINED_SAMPLERS; counter++)
{
......@@ -731,13 +732,17 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
This->IndexFmt = targetStateBlock->IndexFmt;
}
if (This->changed.vertexDecl && This->vertexDecl != targetStateBlock->vertexDecl)
if (This->changed.vertexDecl && This->state.vertex_declaration != targetStateBlock->state.vertex_declaration)
{
TRACE("Updating vertex declaration from %p to %p.\n", This->vertexDecl, targetStateBlock->vertexDecl);
TRACE("Updating vertex declaration from %p to %p.\n",
This->state.vertex_declaration, targetStateBlock->state.vertex_declaration);
if (targetStateBlock->vertexDecl) IWineD3DVertexDeclaration_AddRef(targetStateBlock->vertexDecl);
if (This->vertexDecl) IWineD3DVertexDeclaration_Release(This->vertexDecl);
This->vertexDecl = targetStateBlock->vertexDecl;
if (targetStateBlock->state.vertex_declaration)
IWineD3DVertexDeclaration_AddRef(
(IWineD3DVertexDeclaration *)targetStateBlock->state.vertex_declaration);
if (This->state.vertex_declaration)
IWineD3DVertexDeclaration_Release((IWineD3DVertexDeclaration *)This->state.vertex_declaration);
This->state.vertex_declaration = targetStateBlock->state.vertex_declaration;
}
if (This->changed.material && memcmp(&targetStateBlock->state.material,
......@@ -989,9 +994,9 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Apply(IWineD3DStateBlock *iface)
IWineD3DDevice_SetBaseVertexIndex(device, This->baseVertexIndex);
}
if (This->changed.vertexDecl && This->vertexDecl)
if (This->changed.vertexDecl && This->state.vertex_declaration)
{
IWineD3DDevice_SetVertexDeclaration(device, This->vertexDecl);
IWineD3DDevice_SetVertexDeclaration(device, (IWineD3DVertexDeclaration *)This->state.vertex_declaration);
}
if (This->changed.material)
......
......@@ -2897,7 +2897,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
}
else if (stateblock->state.render_states[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE)
{
if (use_vs(stateblock) || ((IWineD3DVertexDeclarationImpl *)stateblock->vertexDecl)->position_transformed)
if (use_vs(stateblock) || stateblock->state.vertex_declaration->position_transformed)
{
settings->fog = FOG_LINEAR;
}
......
......@@ -2349,6 +2349,8 @@ struct wined3d_stream_state
struct wined3d_state
{
IWineD3DVertexDeclarationImpl *vertex_declaration;
IWineD3DBaseTextureImpl *textures[MAX_COMBINED_SAMPLERS];
DWORD sampler_states[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
DWORD texture_states[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
......@@ -2376,9 +2378,6 @@ struct IWineD3DStateBlockImpl
SAVEDSTATES changed;
struct wined3d_state state;
/* Vertex Shader Declaration */
IWineD3DVertexDeclaration *vertexDecl;
IWineD3DVertexShader *vertexShader;
/* Vertex Shader Constants */
......@@ -3036,7 +3035,7 @@ static inline BOOL use_vs(IWineD3DStateBlockImpl *stateblock)
* stateblock->vertexShader implies a vertex declaration instead of ddraw
* style strided data. */
return (stateblock->vertexShader
&& !((IWineD3DVertexDeclarationImpl *)stateblock->vertexDecl)->position_transformed
&& !stateblock->state.vertex_declaration->position_transformed
&& stateblock->device->vs_selected_mode != SHADER_NONE);
}
......
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