Module: wine Branch: refs/heads/master Commit: d4132cf7d7b336469f6780052a4142bfafe28d84 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=d4132cf7d7b336469f678005...
Author: H. Verbeet hverbeet@gmail.com Date: Tue Mar 28 21:10:44 2006 +0200
wined3d: Move the vshader_ins and pshader_ins arrays into their respective objects.
---
dlls/wined3d/device.c | 2 ++ dlls/wined3d/pixelshader.c | 14 ++++++++------ dlls/wined3d/vertexshader.c | 20 +++++++++++--------- dlls/wined3d/wined3d_private.h | 4 ++++ 4 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 16eac5f..d322e82 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1620,6 +1620,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_Create IWineD3DVertexShaderImpl *object; /* NOTE: impl usage is ok, this is a create */ HRESULT hr = D3D_OK; D3DCREATEOBJECTINSTANCE(object, VertexShader) + object->shader_ins = IWineD3DVertexShaderImpl_shader_ins;
TRACE("(%p) : Created Vertex shader %p\n", This, *ppVertexShader);
@@ -1664,6 +1665,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_Create HRESULT hr = D3D_OK;
D3DCREATEOBJECTINSTANCE(object, PixelShader) + object->shader_ins = IWineD3DPixelShaderImpl_shader_ins; hr = IWineD3DPixelShader_SetFunction(*ppPixelShader, pFunction); if (D3D_OK == hr) { TRACE("(%p) : Created Pixel shader %p\n", This, *ppPixelShader); diff --git a/dlls/wined3d/pixelshader.c b/dlls/wined3d/pixelshader.c index 64fe501..89fe4b9 100644 --- a/dlls/wined3d/pixelshader.c +++ b/dlls/wined3d/pixelshader.c @@ -629,7 +629,7 @@ void pshader_breakp(WINED3DSHADERVECTOR* /** * log, exp, frc, m*x* seems to be macros ins ... to see */ -static CONST SHADER_OPCODE pshader_ins [] = { +CONST SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins[] = { {D3DSIO_NOP, "nop", "NOP", 0, pshader_nop, 0, 0}, {D3DSIO_MOV, "mov", "MOV", 2, pshader_mov, 0, 0}, {D3DSIO_ADD, "add", "ADD", 3, pshader_add, 0, 0}, @@ -746,12 +746,14 @@ inline static const SHADER_OPCODE* pshad DWORD i = 0; DWORD version = This->version; DWORD hex_version = D3DPS_VERSION(version/10, version%10); + const SHADER_OPCODE *shader_ins = This->shader_ins; + /** TODO: use dichotomic search */ - while (NULL != pshader_ins[i].name) { - if (((code & D3DSI_OPCODE_MASK) == pshader_ins[i].opcode) && - (((hex_version >= pshader_ins[i].min_version) && (hex_version <= pshader_ins[i].max_version)) || - ((pshader_ins[i].min_version == 0) && (pshader_ins[i].max_version == 0)))) { - return &pshader_ins[i]; + 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; } diff --git a/dlls/wined3d/vertexshader.c b/dlls/wined3d/vertexshader.c index cfa8f2e..0fd74e3 100644 --- a/dlls/wined3d/vertexshader.c +++ b/dlls/wined3d/vertexshader.c @@ -582,7 +582,7 @@ void vshader_breakp(WINED3DSHADERVECTOR* /** * log, exp, frc, m*x* seems to be macros ins ... to see */ -static CONST SHADER_OPCODE vshader_ins [] = { +CONST SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins[] = { {D3DSIO_NOP, "nop", "NOP", 0, vshader_nop, 0, 0}, {D3DSIO_MOV, "mov", "MOV", 2, vshader_mov, 0, 0}, {D3DSIO_ADD, "add", "ADD", 3, vshader_add, 0, 0}, @@ -691,12 +691,14 @@ static CONST SHADER_OPCODE vshader_ins [ };
-inline static const SHADER_OPCODE* vshader_program_get_opcode(const DWORD code) { +inline static const SHADER_OPCODE* vshader_program_get_opcode(IWineD3DVertexShaderImpl *This, const DWORD code) { DWORD i = 0; + const SHADER_OPCODE *shader_ins = This->shader_ins; + /** TODO: use dichotomic search or hash table */ - while (NULL != vshader_ins[i].name) { - if ((code & D3DSI_OPCODE_MASK) == vshader_ins[i].opcode) { - return &vshader_ins[i]; + while (NULL != shader_ins[i].name) { + if ((code & D3DSI_OPCODE_MASK) == shader_ins[i].opcode) { + return &shader_ins[i]; } ++i; } @@ -1305,7 +1307,7 @@ inline static VOID IWineD3DVertexShaderI pToken += comment_len; continue; } - curOpcode = vshader_program_get_opcode(*pToken); + curOpcode = vshader_program_get_opcode(This, *pToken); ++pToken; /* TODO: dcl's */ /* TODO: Consts */ @@ -1485,7 +1487,7 @@ inline static VOID IWineD3DVertexShaderI continue; }
- curOpcode = vshader_program_get_opcode(*pToken); + curOpcode = vshader_program_get_opcode(This, *pToken); ++pToken; if (NULL == curOpcode) { /* unknown current opcode ... (shouldn't be any!) */ @@ -1781,7 +1783,7 @@ HRESULT WINAPI IWineD3DVertexShaderImpl_ pToken += comment_len; continue ; } - curOpcode = vshader_program_get_opcode(*pToken); + curOpcode = vshader_program_get_opcode(This, *pToken); ++pToken; if (NULL == curOpcode) { i = 0; @@ -2129,7 +2131,7 @@ HRESULT WINAPI IWineD3DVertexShaderImpl_ len += comment_len + 1; continue; } - curOpcode = vshader_program_get_opcode(*pToken); + curOpcode = vshader_program_get_opcode(This, *pToken); ++pToken; ++len; if (NULL == curOpcode) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index cff1ac9..dad25f6 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1181,6 +1181,7 @@ typedef struct IWineD3DVertexShaderImpl IWineD3DDeviceImpl *wineD3DDevice;
/* IWineD3DVertexShaderImpl */ + CONST SHADER_OPCODE *shader_ins; CONST DWORD *function; UINT functionLength;
@@ -1204,6 +1205,7 @@ typedef struct IWineD3DVertexShaderImpl VSHADEROUTPUTDATA output; #endif } IWineD3DVertexShaderImpl; +extern const SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins[]; extern const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl;
/***************************************************************************** @@ -1218,6 +1220,7 @@ typedef struct IWineD3DPixelShaderImpl { IWineD3DDeviceImpl *wineD3DDevice;
/* IWineD3DPixelShaderImpl */ + const SHADER_OPCODE *shader_ins; CONST DWORD *function; UINT functionLength; DWORD version; @@ -1233,5 +1236,6 @@ typedef struct IWineD3DPixelShaderImpl { #endif } IWineD3DPixelShaderImpl;
+extern const SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins[]; extern const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl; #endif