Commit 899c8cdb authored by Ivan Gyurdiev's avatar Ivan Gyurdiev Committed by Alexandre Julliard

wined3d: Create fake input semantics for d3d8 shaders.

Use them to remove the need for loading arrays in two different places.
parent 5b3c500e
......@@ -451,19 +451,6 @@ void primitiveDeclarationConvertToStridedData(
TRACE("Offset %d Stream %d UsageIndex %d\n", element->Offset, element->Stream, element->UsageIndex);
if (useVertexShaderFunction && reg != -1 && (data || streamVBO) ) {
WINED3DGLTYPE glType = glTypeLookup[element->Type];
TRACE("(%p) : Set vertex attrib pointer: reg 0x%08x, d3d type 0x%08x, stride 0x%08lx, data %p)\n", This, reg, element->Type, stride, data);
GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, streamVBO));
checkGLcall("glBindBufferARB");
GL_EXTCALL(glVertexAttribPointerARB(reg, glType.size, glType.glType, glType.normalized, stride, data));
checkGLcall("glVertexAttribPointerARB");
GL_EXTCALL(glEnableVertexAttribArrayARB(reg));
checkGLcall("glEnableVertexAttribArrayARB");
}
if (useVertexShaderFunction)
stride_used = vshader_get_input(This->stateBlock->vertexShader,
element->Usage, element->UsageIndex, &idx);
......
......@@ -609,6 +609,28 @@ static void vshader_set_limits(
}
}
/* This is an internal function,
* used to create fake semantics for shaders
* that don't have them - d3d8 shaders where the declaration
* stores the register for each input
*/
static void vshader_set_input(
IWineD3DVertexShaderImpl* This,
unsigned int regnum,
BYTE usage, BYTE usage_idx) {
/* Fake usage: set reserved bit, usage, usage_idx */
DWORD usage_token = (0x1 << 31) |
(usage << D3DSP_DCL_USAGE_SHIFT) | (usage_idx << D3DSP_DCL_USAGEINDEX_SHIFT);
/* Fake register; set reserved bit, regnum, type: input, wmask: all */
DWORD reg_token = (0x1 << 31) |
D3DSP_WRITEMASK_ALL | (D3DSPR_INPUT << D3DSP_REGTYPE_SHIFT) | regnum;
This->semantics_in[regnum].usage = usage_token;
This->semantics_in[regnum].reg = reg_token;
}
BOOL vshader_get_input(
IWineD3DVertexShader* iface,
BYTE usage_req, BYTE usage_idx_req,
......@@ -637,7 +659,13 @@ BOOL vshader_input_is_color(
IWineD3DVertexShaderImpl* This = (IWineD3DVertexShaderImpl*) iface;
DWORD usage_token = This->semantics_in[regnum].usage;
DWORD usage = (usage_token & D3DSP_DCL_USAGE_MASK) >> D3DSP_DCL_USAGE_SHIFT;
return usage == D3DDECLUSAGE_COLOR;
/* FIXME: D3D8 shader: the semantics token is not the way to
* determine color info, since it is just a fake map to shader inputs */
if (This->vertexDeclaration != NULL)
return FALSE;
else
return usage == D3DDECLUSAGE_COLOR;
}
/** Generate a vertex shader string using either GL_VERTEX_PROGRAM_ARB
......@@ -1077,6 +1105,16 @@ static HRESULT WINAPI IWineD3DVertexShaderImpl_SetFunction(IWineD3DVertexShader
shader_trace_init((IWineD3DBaseShader*) This, pFunction);
vshader_set_limits(This);
/* Preload semantics for d3d8 shaders */
if (This->vertexDeclaration) {
IWineD3DVertexDeclarationImpl* vdecl = (IWineD3DVertexDeclarationImpl*) This->vertexDeclaration;
int i;
for (i = 0; i < vdecl->declarationWNumElements - 1; ++i) {
WINED3DVERTEXELEMENT* element = vdecl->pDeclarationWine + i;
vshader_set_input(This, element->Reg, element->Usage, element->UsageIndex);
}
}
/* Second pass: figure out registers used, semantics, etc.. */
memset(&reg_maps, 0, sizeof(shader_reg_maps));
shader_get_registers_used((IWineD3DBaseShader*) This, &reg_maps,
......
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