wined3d: Share get_opcode.
This commit is contained in:
parent
9ff27bf6bc
commit
1d0c672393
|
@ -54,4 +54,28 @@ int shader_addline(
|
|||
return 0;
|
||||
}
|
||||
|
||||
const SHADER_OPCODE* shader_get_opcode(
|
||||
IWineD3DBaseShader *iface, const DWORD code) {
|
||||
|
||||
IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl*) iface;
|
||||
|
||||
DWORD i = 0;
|
||||
DWORD version = This->baseShader.version;
|
||||
DWORD hex_version = This->baseShader.hex_version;
|
||||
const SHADER_OPCODE *shader_ins = This->baseShader.shader_ins;
|
||||
|
||||
/** TODO: use dichotomic search */
|
||||
while (NULL != shader_ins[i].name) {
|
||||
if (((code & D3DSI_OPCODE_MASK) == shader_ins[i].opcode) &&
|
||||
(((hex_version >= shader_ins[i].min_version) && (hex_version <= shader_ins[i].max_version)) ||
|
||||
((shader_ins[i].min_version == 0) && (shader_ins[i].max_version == 0)))) {
|
||||
return &shader_ins[i];
|
||||
}
|
||||
++i;
|
||||
}
|
||||
FIXME("Unsupported opcode %lx(%ld) masked %lx version %ld\n",
|
||||
code, code, code & D3DSI_OPCODE_MASK, version);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* TODO: Move other shared code here */
|
||||
|
|
|
@ -719,25 +719,6 @@ CONST SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins[] = {
|
|||
{0, NULL, NULL, 0, NULL, 0, 0}
|
||||
};
|
||||
|
||||
inline static const SHADER_OPCODE* pshader_program_get_opcode(IWineD3DPixelShaderImpl *This, const DWORD code) {
|
||||
DWORD i = 0;
|
||||
DWORD version = This->baseShader.version;
|
||||
DWORD hex_version = D3DPS_VERSION(version/10, version%10);
|
||||
const SHADER_OPCODE *shader_ins = This->baseShader.shader_ins;
|
||||
|
||||
/** TODO: use dichotomic search */
|
||||
while (NULL != shader_ins[i].name) {
|
||||
if (((code & D3DSI_OPCODE_MASK) == shader_ins[i].opcode) &&
|
||||
(((hex_version >= shader_ins[i].min_version) && (hex_version <= shader_ins[i].max_version)) ||
|
||||
((shader_ins[i].min_version == 0) && (shader_ins[i].max_version == 0)))) {
|
||||
return &shader_ins[i];
|
||||
}
|
||||
++i;
|
||||
}
|
||||
FIXME("Unsupported opcode %lx(%ld) masked %lx version %ld\n", code, code, code & D3DSI_OPCODE_MASK, version);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline static BOOL pshader_is_version_token(DWORD token) {
|
||||
return 0xFFFF0000 == (token & 0xFFFF0000);
|
||||
}
|
||||
|
@ -945,7 +926,7 @@ inline static void pshader_program_get_registers_used(
|
|||
}
|
||||
|
||||
/* Fetch opcode */
|
||||
curOpcode = pshader_program_get_opcode(This, *pToken);
|
||||
curOpcode = shader_get_opcode((IWineD3DBaseShader*) This, *pToken);
|
||||
++pToken;
|
||||
|
||||
/* Skip declarations (for now) */
|
||||
|
@ -1134,7 +1115,7 @@ inline static VOID IWineD3DPixelShaderImpl_GenerateProgramArbHW(IWineD3DPixelSha
|
|||
code = *pToken;
|
||||
#endif
|
||||
pInstr = pToken;
|
||||
curOpcode = pshader_program_get_opcode(This, *pToken);
|
||||
curOpcode = shader_get_opcode((IWineD3DBaseShader*) This, *pToken);
|
||||
++pToken;
|
||||
if (NULL == curOpcode) {
|
||||
/* unknown current opcode ... (shouldn't be any!) */
|
||||
|
@ -1779,7 +1760,7 @@ HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *iface, C
|
|||
if (!This->baseShader.version) {
|
||||
WARN("(%p) : pixel shader doesn't have a valid version identifier\n", This);
|
||||
}
|
||||
curOpcode = pshader_program_get_opcode(This, *pToken);
|
||||
curOpcode = shader_get_opcode((IWineD3DBaseShader*) This, *pToken);
|
||||
++pToken;
|
||||
++len;
|
||||
if (NULL == curOpcode) {
|
||||
|
|
|
@ -554,21 +554,6 @@ CONST SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins[] = {
|
|||
{0, NULL, NULL, 0, NULL, 0, 0}
|
||||
};
|
||||
|
||||
inline static const SHADER_OPCODE* vshader_program_get_opcode(IWineD3DVertexShaderImpl *This, const DWORD code) {
|
||||
DWORD i = 0;
|
||||
const SHADER_OPCODE *shader_ins = This->baseShader.shader_ins;
|
||||
|
||||
/** TODO: use dichotomic search or hash table */
|
||||
while (NULL != shader_ins[i].name) {
|
||||
if ((code & D3DSI_OPCODE_MASK) == shader_ins[i].opcode) {
|
||||
return &shader_ins[i];
|
||||
}
|
||||
++i;
|
||||
}
|
||||
FIXME("Unsupported opcode %lx\n",code);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline static void vshader_program_dump_vs_param(const DWORD param, int input) {
|
||||
static const char* rastout_reg_names[] = { "oPos", "oFog", "oPts" };
|
||||
static const char swizzle_reg_chars[] = "xyzw";
|
||||
|
@ -1147,7 +1132,7 @@ inline static VOID IWineD3DVertexShaderImpl_GenerateProgramArbHW(IWineD3DVertexS
|
|||
pToken += comment_len;
|
||||
continue;
|
||||
}
|
||||
curOpcode = vshader_program_get_opcode(This, *pToken);
|
||||
curOpcode = shader_get_opcode((IWineD3DBaseShader*) This, *pToken);
|
||||
++pToken;
|
||||
/* TODO: dcl's */
|
||||
/* TODO: Consts */
|
||||
|
@ -1274,7 +1259,7 @@ inline static VOID IWineD3DVertexShaderImpl_GenerateProgramArbHW(IWineD3DVertexS
|
|||
continue;
|
||||
}
|
||||
|
||||
curOpcode = vshader_program_get_opcode(This, *pToken);
|
||||
curOpcode = shader_get_opcode((IWineD3DBaseShader*) This, *pToken);
|
||||
++pToken;
|
||||
if (NULL == curOpcode) {
|
||||
/* unknown current opcode ... (shouldn't be any!) */
|
||||
|
@ -1557,7 +1542,7 @@ HRESULT WINAPI IWineD3DVertexShaderImpl_ExecuteSW(IWineD3DVertexShader* iface, W
|
|||
pToken += comment_len;
|
||||
continue ;
|
||||
}
|
||||
curOpcode = vshader_program_get_opcode(This, *pToken);
|
||||
curOpcode = shader_get_opcode((IWineD3DBaseShader*) This, *pToken);
|
||||
++pToken;
|
||||
if (NULL == curOpcode) {
|
||||
i = 0;
|
||||
|
@ -1907,7 +1892,7 @@ HRESULT WINAPI IWineD3DVertexShaderImpl_SetFunction(IWineD3DVertexShader *iface,
|
|||
len += comment_len + 1;
|
||||
continue;
|
||||
}
|
||||
curOpcode = vshader_program_get_opcode(This, *pToken);
|
||||
curOpcode = shader_get_opcode((IWineD3DBaseShader*) This, *pToken);
|
||||
++pToken;
|
||||
++len;
|
||||
if (NULL == curOpcode) {
|
||||
|
|
|
@ -1220,6 +1220,10 @@ extern int shader_addline(
|
|||
SHADER_BUFFER* buffer,
|
||||
const char* fmt, ...);
|
||||
|
||||
extern const SHADER_OPCODE* shader_get_opcode(
|
||||
IWineD3DBaseShader *iface,
|
||||
const DWORD code);
|
||||
|
||||
/*****************************************************************************
|
||||
* IDirect3DBaseShader implementation structure
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue