Commit 1213c174 authored by Lionel Ulmer's avatar Lionel Ulmer Committed by Alexandre Julliard

- rewrote a little bit the state magagement to remove the RenderState

stucture and use only the state_block code - factorize some code between interface revisions - fix some smalls bugs
parent ede0e8ae
......@@ -26,9 +26,11 @@
#include "d3d.h"
#define MAX_TEXTURES 8
#define MAX_LIGHTS 16
#define HIGHEST_RENDER_STATE 152
#define HIGHEST_TEXTURE_STAGE_STATE 24
#define HIGHEST_LIGHT_STATE 8
/*****************************************************************************
* Predeclare the interface implementation structures
......@@ -45,15 +47,13 @@ typedef struct IDirect3DVertexBufferImpl IDirect3DVertexBufferImpl;
typedef struct STATEBLOCKFLAGS {
BOOL render_state[HIGHEST_RENDER_STATE];
BOOL texture_stage_state[8][HIGHEST_TEXTURE_STAGE_STATE];
BOOL light_state[HIGHEST_LIGHT_STATE];
BOOL texture_stage_state[MAX_TEXTURES][HIGHEST_TEXTURE_STAGE_STATE];
} STATEBLOCKFLAGS;
typedef struct STATEBLOCK {
STATEBLOCKFLAGS set_flags;
DWORD render_state[HIGHEST_RENDER_STATE];
DWORD texture_stage_state[8][HIGHEST_TEXTURE_STAGE_STATE];
DWORD light_state[HIGHEST_LIGHT_STATE];
DWORD texture_stage_state[MAX_TEXTURES][HIGHEST_TEXTURE_STAGE_STATE];
} STATEBLOCK;
/*****************************************************************************
......@@ -188,9 +188,6 @@ typedef struct d3d7clippingplane
* IDirect3DDevice implementation structure
*/
#define MAX_TEXTURES 8
#define MAX_LIGHTS 16
#define WORLDMAT_CHANGED (0x00000001 << 0)
#define VIEWMAT_CHANGED (0x00000001 << 1)
#define PROJMAT_CHANGED (0x00000001 << 2)
......
......@@ -104,7 +104,7 @@ DWORD InitRenderStateTab[] = {
D3DRENDERSTATE_WRAP6, 0,
D3DRENDERSTATE_WRAP7, 0,
D3DRENDERSTATE_CLIPPING, FALSE,
D3DRENDERSTATE_LIGHTING, FALSE, /* FIXME: Should be TRUE */
D3DRENDERSTATE_LIGHTING, TRUE,
D3DRENDERSTATE_EXTENTS, FALSE,
D3DRENDERSTATE_AMBIENT, D3DRGBA(0,0,0,0),
D3DRENDERSTATE_FOGVERTEXMODE, D3DFOG_NONE,
......@@ -160,42 +160,35 @@ void InitDefaultStateBlock(STATEBLOCK* lpStateBlock, int version)
{
int i,j;
TRACE("(%p,%d)\n", lpStateBlock, version);
memset(lpStateBlock,0,sizeof(STATEBLOCK));
memset(lpStateBlock, 0, sizeof(STATEBLOCK));
/* Initialize render states */
for(i=0;i<sizeof(InitRenderStateTab)/4;i+=2)
for(i = 0; i < sizeof(InitRenderStateTab) / sizeof(InitRenderStateTab[0]); i += 2)
{
lpStateBlock->render_state[InitRenderStateTab[i]-1] = InitRenderStateTab[i+1];
lpStateBlock->set_flags.render_state[InitRenderStateTab[i]-1] = TRUE;
}
/* Initialize render states */
for(i=0;i<sizeof(InitLightStateTab)/4;i+=2)
{
lpStateBlock->light_state[InitLightStateTab[i]-1] = InitLightStateTab[i+1];
lpStateBlock->set_flags.light_state[InitLightStateTab[i]-1] = TRUE;
lpStateBlock->render_state[InitRenderStateTab[i] - 1] = InitRenderStateTab[i + 1];
lpStateBlock->set_flags.render_state[InitRenderStateTab[i] - 1] = TRUE;
}
/* Initialize texture stages states */
for(i=0;i<8;i++)
for(i = 0; i < MAX_TEXTURES; i++)
{
for(j=0;j<sizeof(InitTextureStageStateTab)/4;j+=2)
for(j = 0; j < sizeof(InitTextureStageStateTab) / sizeof(InitTextureStageStateTab[0]); j += 2)
{
lpStateBlock->texture_stage_state[i][InitTextureStageStateTab[j]-1] = InitTextureStageStateTab[j+1];
lpStateBlock->set_flags.texture_stage_state[i][InitTextureStageStateTab[j]-1] = TRUE;
lpStateBlock->texture_stage_state[i][InitTextureStageStateTab[j] - 1] = InitTextureStageStateTab[j + 1];
lpStateBlock->set_flags.texture_stage_state[i][InitTextureStageStateTab[j] - 1] = TRUE;
}
/* Map texture coords 0 to stage 0, 1 to stage 1, etc... */
lpStateBlock->texture_stage_state[i][D3DTSS_TEXCOORDINDEX-1] = i;
lpStateBlock->set_flags.texture_stage_state[i][D3DTSS_TEXCOORDINDEX-1] = TRUE;
lpStateBlock->texture_stage_state[i][D3DTSS_TEXCOORDINDEX - 1] = i;
lpStateBlock->set_flags.texture_stage_state[i][D3DTSS_TEXCOORDINDEX - 1] = TRUE;
}
/* The first texture is particular, update it consequently */
lpStateBlock->texture_stage_state[0][D3DTSS_COLOROP-1] = D3DTOP_MODULATE;
lpStateBlock->texture_stage_state[0][D3DTSS_ALPHAOP-1] = D3DTOP_SELECTARG1;
lpStateBlock->texture_stage_state[0][D3DTSS_COLOROP - 1] = D3DTOP_MODULATE;
lpStateBlock->texture_stage_state[0][D3DTSS_ALPHAOP - 1] = D3DTOP_SELECTARG1;
/* Updates for particular versions */
if ((version == 1)||(version==2))
lpStateBlock->render_state[D3DRENDERSTATE_SPECULARENABLE-1] = TRUE;
if ((version == 1) || (version==2))
lpStateBlock->render_state[D3DRENDERSTATE_SPECULARENABLE - 1] = TRUE;
}
HRESULT WINAPI
......@@ -1112,12 +1105,8 @@ Main_IDirect3DDeviceImpl_3_2T_GetLightState(LPDIRECT3DDEVICE3 iface,
LPDWORD lpdwLightState)
{
ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);
TRACE("(%p/%p)->(%08x,%p)\n", This, iface, dwLightStateType, lpdwLightState);
if (lpdwLightState && dwLightStateType && (dwLightStateType <= HIGHEST_LIGHT_STATE) ) {
*lpdwLightState = This->state_block.light_state[dwLightStateType-1];
FIXME("(%p/%p)->(%08x,%p): stub !\n", This, iface, dwLightStateType, lpdwLightState);
return DD_OK;
}
return DDERR_INVALIDPARAMS;
}
HRESULT WINAPI
......
......@@ -187,7 +187,6 @@ static void execute(IDirect3DExecuteBufferImpl *This,
IDirect3DDeviceImpl *lpDevice,
IDirect3DViewportImpl *lpViewport)
{
IDirect3DDeviceGLImpl* lpDeviceGL = (IDirect3DDeviceGLImpl*) lpDevice;
/* DWORD bs = This->desc.dwBufferSize; */
DWORD vs = This->data.dwVertexOffset;
/* DWORD vc = This->data.dwVertexCount; */
......@@ -441,8 +440,10 @@ static void execute(IDirect3DExecuteBufferImpl *This,
for (i = 0; i < count; i++) {
LPD3DSTATE ci = (LPD3DSTATE) instr;
/* Handle the state transform */
set_render_state(lpDeviceGL, ci->u1.drstRenderStateType, ci->u2.dwArg[0]);
LEAVE_GL();
IDirect3DDevice7_SetRenderState(ICOM_INTERFACE(lpDevice, IDirect3DDevice7),
ci->u1.drstRenderStateType, ci->u2.dwArg[0]);
ENTER_GL();
instr += size;
}
......
......@@ -58,32 +58,6 @@ extern void (*wine_tsx11_unlock_ptr)(void);
extern const GUID IID_D3DDEVICE_OpenGL;
typedef struct render_state {
/* This is used for the device mode */
GLenum src, dst;
/* This is used for textures */
GLenum mag, min;
/* This is needed for the Alpha stuff */
GLenum alpha_func;
GLclampf alpha_ref;
BOOLEAN alpha_blend_enable;
/* This is needed for the stencil stuff */
GLint stencil_ref;
GLuint stencil_mask;
GLenum stencil_func;
BOOLEAN stencil_enable;
GLenum stencil_fail, stencil_zfail, stencil_pass;
/* This is needed for proper lighting */
BOOLEAN lighting_enable, specular_enable;
D3DMATERIALCOLORSOURCE color_diffuse, color_specular, color_ambient, color_emissive;
/* This is needed to re-enable fogging when XYZRHW and XYZ primitives are mixed */
BOOLEAN fog_on;
} RenderState;
typedef struct IDirect3DGLImpl
{
struct IDirect3DImpl parent;
......@@ -127,9 +101,6 @@ typedef struct IDirect3DDeviceGLImpl
GLXContext gl_context;
/* The current render state */
RenderState render_state;
/* The last type of vertex drawn */
GL_TRANSFORM_STATE transform_state;
......@@ -167,14 +138,11 @@ extern HRESULT gltex_upload_texture(IDirectDrawSurfaceImpl *This) ;
/* Used to set-up our orthographic projection */
extern void d3ddevice_set_ortho(IDirect3DDeviceImpl *This) ;
/* Common functions defined in d3dcommon.c */
void set_render_state(IDirect3DDeviceGLImpl* This,
D3DRENDERSTATETYPE dwRenderStateType, DWORD dwRenderState);
void store_render_state(D3DRENDERSTATETYPE dwRenderStateType, DWORD dwRenderState,
STATEBLOCK* lpStateBlock);
void get_render_state(D3DRENDERSTATETYPE dwRenderStateType, LPDWORD lpdwRenderState,
STATEBLOCK* lpStateBlock);
void apply_render_state(IDirect3DDeviceGLImpl* This, STATEBLOCK* lpStateBlock);
/* Rendering state management functions */
extern void set_render_state(IDirect3DDeviceImpl* This, D3DRENDERSTATETYPE dwRenderStateType, STATEBLOCK *lpStateBlock);
extern void store_render_state(IDirect3DDeviceImpl *This, D3DRENDERSTATETYPE dwRenderStateType, DWORD dwRenderState, STATEBLOCK* lpStateBlock);
extern void get_render_state(IDirect3DDeviceImpl *This, D3DRENDERSTATETYPE dwRenderStateType, LPDWORD lpdwRenderState, STATEBLOCK* lpStateBlock);
extern void apply_render_state(IDirect3DDeviceImpl* This, STATEBLOCK* lpStateBlock);
/* This structure contains all the function pointers to OpenGL extensions
that are used by Wine */
......
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