wined3d: Break the viewport out of the vertex declaration state.
This commit is contained in:
parent
f2a3ad2481
commit
0d700bef5d
|
@ -3055,26 +3055,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetViewport(IWineD3DDevice *iface, CONS
|
|||
TRACE("Recording... not performing anything\n");
|
||||
return WINED3D_OK;
|
||||
}
|
||||
This->viewport_changed = TRUE;
|
||||
|
||||
ENTER_GL();
|
||||
|
||||
TRACE("(%p) : x=%d, y=%d, wid=%d, hei=%d, minz=%f, maxz=%f\n", This,
|
||||
pViewport->X, pViewport->Y, pViewport->Width, pViewport->Height, pViewport->MinZ, pViewport->MaxZ);
|
||||
|
||||
glDepthRange(pViewport->MinZ, pViewport->MaxZ);
|
||||
checkGLcall("glDepthRange");
|
||||
/* Note: GL requires lower left, DirectX supplies upper left */
|
||||
/* TODO: replace usage of renderTarget with context management */
|
||||
glViewport(pViewport->X,
|
||||
(((IWineD3DSurfaceImpl *)This->render_targets[0])->currentDesc.Height - (pViewport->Y + pViewport->Height)),
|
||||
pViewport->Width, pViewport->Height);
|
||||
|
||||
checkGLcall("glViewport");
|
||||
|
||||
LEAVE_GL();
|
||||
|
||||
/* Todo: move the gl code too */
|
||||
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VIEWPORT);
|
||||
return WINED3D_OK;
|
||||
|
||||
|
|
|
@ -2059,8 +2059,6 @@ static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock) {
|
|||
*/
|
||||
if (useVertexShaderFunction) {
|
||||
device->posFixup[1] = device->render_offscreen ? -1.0 : 1.0;
|
||||
device->posFixup[2] = 0.9 / stateblock->viewport.Width;
|
||||
device->posFixup[3] = -0.9 / stateblock->viewport.Height;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2071,7 +2069,9 @@ static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock) {
|
|||
/* TODO: Move this mainly to the viewport state and only apply when the vp has changed
|
||||
* or transformed / untransformed was switched
|
||||
*/
|
||||
if(!isStateDirty(stateblock->wineD3DDevice, STATE_TRANSFORM(WINED3DTS_PROJECTION))) {
|
||||
if(wasrhw != device->last_was_rhw &&
|
||||
!isStateDirty(stateblock->wineD3DDevice, STATE_TRANSFORM(WINED3DTS_PROJECTION)) &&
|
||||
!isStateDirty(stateblock->wineD3DDevice, STATE_VIEWPORT)) {
|
||||
transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION), stateblock);
|
||||
}
|
||||
/* World matrix needs reapplication here only if we're switching between rhw and non-rhw
|
||||
|
@ -2097,6 +2097,25 @@ static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock) {
|
|||
}
|
||||
}
|
||||
|
||||
static void viewport(DWORD state, IWineD3DStateBlockImpl *stateblock) {
|
||||
glDepthRange(stateblock->viewport.MinZ, stateblock->viewport.MaxZ);
|
||||
checkGLcall("glDepthRange");
|
||||
/* Note: GL requires lower left, DirectX supplies upper left */
|
||||
/* TODO: replace usage of renderTarget with context management */
|
||||
glViewport(stateblock->viewport.X,
|
||||
(((IWineD3DSurfaceImpl *)stateblock->wineD3DDevice->render_targets[0])->currentDesc.Height - (stateblock->viewport.Y + stateblock->viewport.Height)),
|
||||
stateblock->viewport.Width, stateblock->viewport.Height);
|
||||
|
||||
checkGLcall("glViewport");
|
||||
|
||||
stateblock->wineD3DDevice->posFixup[2] = 0.9 / stateblock->viewport.Width;
|
||||
stateblock->wineD3DDevice->posFixup[3] = -0.9 / stateblock->viewport.Height;
|
||||
if(!isStateDirty(stateblock->wineD3DDevice, STATE_TRANSFORM(D3DTS_PROJECTION))) {
|
||||
transform_projection(STATE_TRANSFORM(D3DTS_PROJECTION), stateblock);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const struct StateEntry StateTable[] =
|
||||
{
|
||||
/* State name representative, apply function */
|
||||
|
@ -3114,6 +3133,6 @@ const struct StateEntry StateTable[] =
|
|||
{ /* , STATE_STREAMSRC */ STATE_VDECL, vertexdeclaration },
|
||||
{ /* , STATE_VDECL */ STATE_VDECL, vertexdeclaration },
|
||||
{ /* , STATE_VSHADER */ STATE_VDECL, vertexdeclaration },
|
||||
{ /* , STATE_VIEWPORT */ STATE_VDECL, vertexdeclaration },
|
||||
{ /* , STATE_VIEWPORT */ STATE_VIEWPORT, viewport },
|
||||
|
||||
};
|
||||
|
|
|
@ -565,7 +565,6 @@ typedef struct IWineD3DDeviceImpl
|
|||
/* Optimization */
|
||||
BOOL view_ident; /* true iff view matrix is identity */
|
||||
BOOL last_was_rhw; /* true iff last draw_primitive was in xyzrhw mode */
|
||||
BOOL viewport_changed; /* Was the viewport changed since the last draw? */
|
||||
GLenum tracking_parm; /* Which source is tracking current colour */
|
||||
LONG tracking_color; /* used iff GL_COLOR_MATERIAL was enabled */
|
||||
#define DISABLED_TRACKING 0 /* Disabled */
|
||||
|
|
Loading…
Reference in New Issue