Avoid the use of glGet when we know the information locally.

This commit is contained in:
Jason Edmeades 2003-06-04 22:02:06 +00:00 committed by Alexandre Julliard
parent 84cd1925fe
commit 2eaf05bfd5
3 changed files with 22 additions and 32 deletions

View File

@ -322,6 +322,8 @@ struct IDirect3DDevice8Impl
UINT srcBlend; UINT srcBlend;
UINT dstBlend; UINT dstBlend;
UINT alphafunc;
UINT stencilfunc;
/* State block related */ /* State block related */
BOOL isRecordingState; BOOL isRecordingState;

View File

@ -1234,7 +1234,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_Present(LPDIRECT3DDEVICE8 iface, CONST REC
ENTER_GL(); ENTER_GL();
glXSwapBuffers(This->display, This->drawable); glXSwapBuffers(This->display, This->drawable);
checkGLcall("glXSwapBuffers"); /* Dont call checkGLcall, as glGetError is not applicable here */
TRACE("glXSwapBuffers called, Starting new frame");
LEAVE_GL(); LEAVE_GL();
@ -2922,10 +2923,7 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
case D3DRS_ALPHAFUNC : case D3DRS_ALPHAFUNC :
{ {
int glParm = GL_LESS; int glParm = GL_LESS;
float ref = 1.0; float ref = ((float) This->StateBlock->renderstate[D3DRS_ALPHAREF]) / 255.0f;
glGetFloatv(GL_ALPHA_TEST_REF, &ref);
checkGLcall("glGetFloatv(GL_ALPHA_TEST_REF, &ref);");
switch ((D3DCMPFUNC) Value) { switch ((D3DCMPFUNC) Value) {
case D3DCMP_NEVER: glParm=GL_NEVER; break; case D3DCMP_NEVER: glParm=GL_NEVER; break;
@ -2941,18 +2939,16 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
} }
TRACE("glAlphaFunc with Parm=%x, ref=%f\n", glParm, ref); TRACE("glAlphaFunc with Parm=%x, ref=%f\n", glParm, ref);
glAlphaFunc(glParm, ref); glAlphaFunc(glParm, ref);
This->alphafunc = glParm;
checkGLcall("glAlphaFunc"); checkGLcall("glAlphaFunc");
} }
break; break;
case D3DRS_ALPHAREF : case D3DRS_ALPHAREF :
{ {
int glParm = GL_LESS; int glParm = This->alphafunc;
float ref = 1.0f; float ref = 1.0f;
glGetIntegerv(GL_ALPHA_TEST_FUNC, &glParm);
checkGLcall("glGetFloatv(GL_ALPHA_TEST_FUNC, &glParm);");
ref = ((float) Value) / 255.0f; ref = ((float) Value) / 255.0f;
TRACE("glAlphaFunc with Parm=%x, ref=%f\n", glParm, ref); TRACE("glAlphaFunc with Parm=%x, ref=%f\n", glParm, ref);
glAlphaFunc(glParm, ref); glAlphaFunc(glParm, ref);
@ -3075,13 +3071,8 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
case D3DRS_STENCILFUNC : case D3DRS_STENCILFUNC :
{ {
int glParm = GL_ALWAYS; int glParm = GL_ALWAYS;
int ref = 0; int ref = This->StateBlock->renderstate[D3DRS_STENCILREF];
GLuint mask = 0xFFFFFFFF; GLuint mask = This->StateBlock->renderstate[D3DRS_STENCILMASK];
glGetIntegerv(GL_STENCIL_REF, &ref);
checkGLcall("glGetFloatv(GL_STENCIL_REF, &ref);");
glGetIntegerv(GL_STENCIL_VALUE_MASK, &mask);
checkGLcall("glGetFloatv(GL_STENCIL_VALUE_MASK, &glParm);");
switch ((D3DCMPFUNC) Value) { switch ((D3DCMPFUNC) Value) {
case D3DCMP_NEVER: glParm=GL_NEVER; break; case D3DCMP_NEVER: glParm=GL_NEVER; break;
@ -3103,14 +3094,9 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
case D3DRS_STENCILREF : case D3DRS_STENCILREF :
{ {
int glParm = GL_ALWAYS; int glParm = This->stencilfunc;
int ref = 0; int ref = 0;
GLuint mask = 0xFFFFFFFF; GLuint mask = This->StateBlock->renderstate[D3DRS_STENCILMASK];
glGetIntegerv(GL_STENCIL_FUNC, &glParm);
checkGLcall("glGetFloatv(GL_STENCIL_FUNC, &glParm);");
glGetIntegerv(GL_STENCIL_VALUE_MASK, &mask);
checkGLcall("glGetFloatv(GL_STENCIL_VALUE_MASK, &glParm);");
ref = Value; ref = Value;
TRACE("glStencilFunc with Parm=%x, ref=%d, mask=%x\n", glParm, ref, mask); TRACE("glStencilFunc with Parm=%x, ref=%d, mask=%x\n", glParm, ref, mask);
@ -3121,15 +3107,10 @@ HRESULT WINAPI IDirect3DDevice8Impl_SetRenderState(LPDIRECT3DDEVICE8 iface, D3
case D3DRS_STENCILMASK : case D3DRS_STENCILMASK :
{ {
int glParm = GL_ALWAYS; int glParm = This->stencilfunc;
int ref = 0.0; int ref = This->StateBlock->renderstate[D3DRS_STENCILREF];
GLuint mask = Value; GLuint mask = Value;
glGetIntegerv(GL_STENCIL_REF, &ref);
checkGLcall("glGetFloatv(GL_STENCIL_REF, &ref);");
glGetIntegerv(GL_STENCIL_FUNC, &glParm);
checkGLcall("glGetFloatv(GL_STENCIL_FUNC, &glParm);");
TRACE("glStencilFunc with Parm=%x, ref=%d, mask=%x\n", glParm, ref, mask); TRACE("glStencilFunc with Parm=%x, ref=%d, mask=%x\n", glParm, ref, mask);
glStencilFunc(glParm, ref, mask); glStencilFunc(glParm, ref, mask);
checkGLcall("glStencilFunc"); checkGLcall("glStencilFunc");

View File

@ -106,9 +106,16 @@ HRESULT WINAPI IDirect3DDeviceImpl_InitStartupStateBlock(IDirect3DDevice8Impl* T
IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP); IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILFAIL, D3DSTENCILOP_KEEP);
IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP); IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP);
IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILPASS, D3DSTENCILOP_KEEP); IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILPASS, D3DSTENCILOP_KEEP);
/* Setting stencil func also uses values for stencil ref/mask, so manually set defaults
* so only a single call performed (and ensure defaults initialized before making that call)
*
* IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILREF, 0);
* IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILMASK, 0xFFFFFFFF);
*/
This->StateBlock->renderstate[D3DRS_STENCILREF] = 0;
This->StateBlock->renderstate[D3DRS_STENCILMASK] = 0xFFFFFFFF;
IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILFUNC, D3DCMP_ALWAYS); IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILFUNC, D3DCMP_ALWAYS);
IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILREF, 0);
IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILMASK, 0xFFFFFFFF);
IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILWRITEMASK, 0xFFFFFFFF); IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_STENCILWRITEMASK, 0xFFFFFFFF);
IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_TEXTUREFACTOR, 0xFFFFFFFF); IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_TEXTUREFACTOR, 0xFFFFFFFF);
IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_WRAP0, 0); IDirect3DDevice8Impl_SetRenderState(iface, D3DRS_WRAP0, 0);