wined3d: Fix D3DCOLOR swizzling in shaders.

This commit is contained in:
H. Verbeet 2006-08-05 18:15:42 +02:00 committed by Alexandre Julliard
parent ef87a40c72
commit 219ca7c2a0
1 changed files with 24 additions and 6 deletions

View File

@ -661,13 +661,31 @@ BOOL vshader_input_is_color(
IWineD3DVertexShaderImpl* This = (IWineD3DVertexShaderImpl*) iface; IWineD3DVertexShaderImpl* This = (IWineD3DVertexShaderImpl*) iface;
DWORD usage_token = This->semantics_in[regnum].usage; DWORD usage_token = This->semantics_in[regnum].usage;
DWORD usage = (usage_token & D3DSP_DCL_USAGE_MASK) >> D3DSP_DCL_USAGE_SHIFT; DWORD usage = (usage_token & D3DSP_DCL_USAGE_MASK) >> D3DSP_DCL_USAGE_SHIFT;
DWORD usage_idx = (usage_token & D3DSP_DCL_USAGEINDEX_MASK) >> D3DSP_DCL_USAGEINDEX_SHIFT;
/* FIXME: D3D8 shader: the semantics token is not the way to IWineD3DVertexDeclarationImpl *vertexDeclaration = NULL;
* determine color info, since it is just a fake map to shader inputs */ if (This->vertexDeclaration) {
if (This->vertexDeclaration != NULL) /* D3D8 declaration */
return FALSE; vertexDeclaration = (IWineD3DVertexDeclarationImpl *)This->vertexDeclaration;
else } else {
return usage == D3DDECLUSAGE_COLOR; /* D3D9 declaration */
vertexDeclaration = (IWineD3DVertexDeclarationImpl *)((IWineD3DDeviceImpl *)This->wineD3DDevice)->stateBlock->vertexDecl;
}
if (vertexDeclaration) {
int i;
/* Find the declaration element that matches our register, then check
* if it has D3DCOLOR as it's type. This works for both d3d8 and d3d9. */
for (i = 0; i < vertexDeclaration->declarationWNumElements-1; ++i) {
WINED3DVERTEXELEMENT *element = vertexDeclaration->pDeclarationWine + i;
if ((element->Usage == usage && element->UsageIndex == usage_idx)) {
return element->Type == WINED3DDECLTYPE_D3DCOLOR;
}
}
}
ERR("Either no vertexdeclaration present, or register not matched. This should never happen.\n");
return FALSE;
} }
/** Generate a vertex shader string using either GL_VERTEX_PROGRAM_ARB /** Generate a vertex shader string using either GL_VERTEX_PROGRAM_ARB