Context now uses Renderer::setViewport.

TRAC #22116 Signed-off-by: Shannon Woods Signed-off-by: Daniel Koch git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1455 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 3884e2c2
...@@ -352,7 +352,6 @@ void Context::markAllStateDirty() ...@@ -352,7 +352,6 @@ void Context::markAllStateDirty()
mAppliedStencilbufferSerial = 0; mAppliedStencilbufferSerial = 0;
mAppliedIBSerial = 0; mAppliedIBSerial = 0;
mDepthStencilInitialized = false; mDepthStencilInitialized = false;
mViewportInitialized = false;
mRenderTargetDescInitialized = false; mRenderTargetDescInitialized = false;
mVertexDeclarationCache.markStateDirty(); mVertexDeclarationCache.markStateDirty();
...@@ -1826,69 +1825,32 @@ bool Context::applyRenderTarget(bool ignoreViewport) ...@@ -1826,69 +1825,32 @@ bool Context::applyRenderTarget(bool ignoreViewport)
mRenderTargetDescInitialized = true; mRenderTargetDescInitialized = true;
} }
D3DVIEWPORT9 viewport; Rectangle viewport = mState.viewport;
float zNear = clamp01(mState.zNear); float zNear = clamp01(mState.zNear);
float zFar = clamp01(mState.zFar); float zFar = clamp01(mState.zFar);
if (ignoreViewport) if (ignoreViewport)
{ {
viewport.X = 0; viewport.x = 0;
viewport.Y = 0; viewport.y = 0;
viewport.Width = mRenderTargetDesc.width; viewport.width = mRenderTargetDesc.width;
viewport.Height = mRenderTargetDesc.height; viewport.height = mRenderTargetDesc.height;
viewport.MinZ = 0.0f; zNear = 0.0f;
viewport.MaxZ = 1.0f; zFar = 1.0f;
}
else
{
viewport.X = clamp(mState.viewport.x, 0L, static_cast<LONG>(mRenderTargetDesc.width));
viewport.Y = clamp(mState.viewport.y, 0L, static_cast<LONG>(mRenderTargetDesc.height));
viewport.Width = clamp(mState.viewport.width, 0L, static_cast<LONG>(mRenderTargetDesc.width) - static_cast<LONG>(viewport.X));
viewport.Height = clamp(mState.viewport.height, 0L, static_cast<LONG>(mRenderTargetDesc.height) - static_cast<LONG>(viewport.Y));
} }
if (viewport.Width <= 0 || viewport.Height <= 0) ProgramBinary *programBinary = mState.currentProgram ? getCurrentProgramBinary() : NULL;
{
return false; // Nothing to render
}
if (renderTargetChanged || !mViewportInitialized || memcmp(&viewport, &mSetViewport, sizeof mSetViewport) != 0) if (!mRenderer->setViewport(viewport, zNear, zFar, mRenderTargetDesc.width, mRenderTargetDesc.height,
programBinary, mDxUniformsDirty))
{ {
mDevice->SetViewport(&viewport); return false;
mSetViewport = viewport;
mViewportInitialized = true;
mDxUniformsDirty = true;
} }
mDxUniformsDirty = false;
mRenderer->setScissorRectangle(mState.scissor, static_cast<int>(mRenderTargetDesc.width), mRenderer->setScissorRectangle(mState.scissor, static_cast<int>(mRenderTargetDesc.width),
static_cast<int>(mRenderTargetDesc.height)); static_cast<int>(mRenderTargetDesc.height));
if (mState.currentProgram && mDxUniformsDirty)
{
ProgramBinary *programBinary = getCurrentProgramBinary();
GLint halfPixelSize = programBinary->getDxHalfPixelSizeLocation();
GLfloat xy[2] = {1.0f / viewport.Width, -1.0f / viewport.Height};
programBinary->setUniform2fv(halfPixelSize, 1, xy);
// These values are used for computing gl_FragCoord in Program::linkVaryings().
GLint coord = programBinary->getDxCoordLocation();
GLfloat whxy[4] = {mState.viewport.width / 2.0f, mState.viewport.height / 2.0f,
(float)mState.viewport.x + mState.viewport.width / 2.0f,
(float)mState.viewport.y + mState.viewport.height / 2.0f};
programBinary->setUniform4fv(coord, 1, whxy);
GLint depth = programBinary->getDxDepthLocation();
GLfloat dz[2] = {(zFar - zNear) / 2.0f, (zNear + zFar) / 2.0f};
programBinary->setUniform2fv(depth, 1, dz);
GLint depthRange = programBinary->getDxDepthRangeLocation();
GLfloat nearFarDiff[3] = {zNear, zFar, zFar - zNear};
programBinary->setUniform3fv(depthRange, 1, nearFarDiff);
mDxUniformsDirty = false;
}
return true; return true;
} }
......
...@@ -550,8 +550,6 @@ class Context ...@@ -550,8 +550,6 @@ class Context
unsigned int mAppliedStencilbufferSerial; unsigned int mAppliedStencilbufferSerial;
unsigned int mAppliedIBSerial; unsigned int mAppliedIBSerial;
bool mDepthStencilInitialized; bool mDepthStencilInitialized;
bool mViewportInitialized;
D3DVIEWPORT9 mSetViewport;
bool mRenderTargetDescInitialized; bool mRenderTargetDescInitialized;
rx::RenderTarget::Desc mRenderTargetDesc; rx::RenderTarget::Desc mRenderTargetDesc;
bool mDxUniformsDirty; bool mDxUniformsDirty;
......
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