Refactored Renderer::setViewport to no longer take render target size arguments.

TRAC #22145 Signed-off-by: Nicolas Capens Signed-off-by: Daniel Koch git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1515 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 04f1b33c
...@@ -1754,8 +1754,7 @@ bool Context::applyRenderTarget(bool ignoreViewport) ...@@ -1754,8 +1754,7 @@ bool Context::applyRenderTarget(bool ignoreViewport)
ProgramBinary *programBinary = mState.currentProgram ? getCurrentProgramBinary() : NULL; ProgramBinary *programBinary = mState.currentProgram ? getCurrentProgramBinary() : NULL;
if (!mRenderer->setViewport(viewport, zNear, zFar, mRenderTargetDesc.width, mRenderTargetDesc.height, if (!mRenderer->setViewport(viewport, zNear, zFar, programBinary, mDxUniformsDirty))
programBinary, mDxUniformsDirty))
{ {
return false; return false;
} }
......
...@@ -88,8 +88,7 @@ class Renderer ...@@ -88,8 +88,7 @@ class Renderer
int stencilBackRef, bool frontFaceCCW, unsigned int stencilSize) = 0; int stencilBackRef, bool frontFaceCCW, unsigned int stencilSize) = 0;
virtual void setScissorRectangle(const gl::Rectangle &scissor) = 0; virtual void setScissorRectangle(const gl::Rectangle &scissor) = 0;
virtual bool setViewport(const gl::Rectangle& viewport, float zNear, float zFar, virtual bool setViewport(const gl::Rectangle &viewport, float zNear, float zFar,
unsigned int renderTargetWidth, unsigned int renderTargetHeight,
gl::ProgramBinary *currentProgram, bool forceSetUniforms) = 0; gl::ProgramBinary *currentProgram, bool forceSetUniforms) = 0;
virtual bool applyRenderTarget(gl::Framebuffer *frameBuffer) = 0; virtual bool applyRenderTarget(gl::Framebuffer *frameBuffer) = 0;
......
...@@ -368,18 +368,17 @@ void Renderer11::setScissorRectangle(const gl::Rectangle &scissor) ...@@ -368,18 +368,17 @@ void Renderer11::setScissorRectangle(const gl::Rectangle &scissor)
mForceSetScissor = false; mForceSetScissor = false;
} }
bool Renderer11::setViewport(const gl::Rectangle& viewport, float zNear, float zFar, bool Renderer11::setViewport(const gl::Rectangle &viewport, float zNear, float zFar,
unsigned int renderTargetWidth, unsigned int renderTargetHeight,
gl::ProgramBinary *currentProgram, bool forceSetUniforms) gl::ProgramBinary *currentProgram, bool forceSetUniforms)
{ {
bool viewportChanged = mForceSetViewport || memcmp(&viewport, &mCurViewport, sizeof(gl::Rectangle)) != 0 || bool viewportChanged = mForceSetViewport || memcmp(&viewport, &mCurViewport, sizeof(gl::Rectangle)) != 0 ||
zNear != mCurNear || zFar != mCurFar; zNear != mCurNear || zFar != mCurFar;
D3D11_VIEWPORT dxViewport; D3D11_VIEWPORT dxViewport;
dxViewport.TopLeftX = gl::clamp(viewport.x, 0, static_cast<int>(renderTargetWidth)); dxViewport.TopLeftX = gl::clamp(viewport.x, 0, static_cast<int>(mRenderTargetDesc.width));
dxViewport.TopLeftY = gl::clamp(viewport.y, 0, static_cast<int>(renderTargetHeight)); dxViewport.TopLeftY = gl::clamp(viewport.y, 0, static_cast<int>(mRenderTargetDesc.height));
dxViewport.Width = gl::clamp(viewport.width, 0, static_cast<int>(renderTargetWidth) - static_cast<int>(dxViewport.TopLeftX)); dxViewport.Width = gl::clamp(viewport.width, 0, static_cast<int>(mRenderTargetDesc.width) - static_cast<int>(dxViewport.TopLeftX));
dxViewport.Height = gl::clamp(viewport.height, 0, static_cast<int>(renderTargetHeight) - static_cast<int>(dxViewport.TopLeftY)); dxViewport.Height = gl::clamp(viewport.height, 0, static_cast<int>(mRenderTargetDesc.height) - static_cast<int>(dxViewport.TopLeftY));
dxViewport.MinDepth = zNear; dxViewport.MinDepth = zNear;
dxViewport.MaxDepth = zFar; dxViewport.MaxDepth = zFar;
......
...@@ -55,8 +55,7 @@ class Renderer11 : public Renderer ...@@ -55,8 +55,7 @@ class Renderer11 : public Renderer
int stencilBackRef, bool frontFaceCCW, unsigned int stencilSize); int stencilBackRef, bool frontFaceCCW, unsigned int stencilSize);
virtual void setScissorRectangle(const gl::Rectangle &scissor); virtual void setScissorRectangle(const gl::Rectangle &scissor);
virtual bool setViewport(const gl::Rectangle& viewport, float zNear, float zFar, virtual bool setViewport(const gl::Rectangle &viewport, float zNear, float zFar,
unsigned int renderTargetWidth, unsigned int renderTargetHeight,
gl::ProgramBinary *currentProgram, bool forceSetUniforms); gl::ProgramBinary *currentProgram, bool forceSetUniforms);
virtual bool applyPrimitiveType(GLenum mode, GLsizei count); virtual bool applyPrimitiveType(GLenum mode, GLsizei count);
......
...@@ -919,18 +919,17 @@ void Renderer9::setScissorRectangle(const gl::Rectangle &scissor) ...@@ -919,18 +919,17 @@ void Renderer9::setScissorRectangle(const gl::Rectangle &scissor)
mForceSetScissor = false; mForceSetScissor = false;
} }
bool Renderer9::setViewport(const gl::Rectangle& viewport, float zNear, float zFar, bool Renderer9::setViewport(const gl::Rectangle &viewport, float zNear, float zFar,
unsigned int renderTargetWidth, unsigned int renderTargetHeight,
gl::ProgramBinary *currentProgram, bool forceSetUniforms) gl::ProgramBinary *currentProgram, bool forceSetUniforms)
{ {
bool viewportChanged = mForceSetViewport || memcmp(&viewport, &mCurViewport, sizeof(gl::Rectangle)) != 0 || bool viewportChanged = mForceSetViewport || memcmp(&viewport, &mCurViewport, sizeof(gl::Rectangle)) != 0 ||
zNear != mCurNear || zFar != mCurFar; zNear != mCurNear || zFar != mCurFar;
D3DVIEWPORT9 dxViewport; D3DVIEWPORT9 dxViewport;
dxViewport.X = gl::clamp(viewport.x, 0, static_cast<int>(renderTargetWidth)); dxViewport.X = gl::clamp(viewport.x, 0, static_cast<int>(mRenderTargetDesc.width));
dxViewport.Y = gl::clamp(viewport.y, 0, static_cast<int>(renderTargetHeight)); dxViewport.Y = gl::clamp(viewport.y, 0, static_cast<int>(mRenderTargetDesc.height));
dxViewport.Width = gl::clamp(viewport.width, 0, static_cast<int>(renderTargetWidth) - static_cast<int>(dxViewport.X)); dxViewport.Width = gl::clamp(viewport.width, 0, static_cast<int>(mRenderTargetDesc.width) - static_cast<int>(dxViewport.X));
dxViewport.Height = gl::clamp(viewport.height, 0, static_cast<int>(renderTargetHeight) - static_cast<int>(dxViewport.Y)); dxViewport.Height = gl::clamp(viewport.height, 0, static_cast<int>(mRenderTargetDesc.height) - static_cast<int>(dxViewport.Y));
dxViewport.MinZ = zNear; dxViewport.MinZ = zNear;
dxViewport.MaxZ = zFar; dxViewport.MaxZ = zFar;
......
...@@ -90,8 +90,7 @@ class Renderer9 : public Renderer ...@@ -90,8 +90,7 @@ class Renderer9 : public Renderer
int stencilBackRef, bool frontFaceCCW, unsigned int stencilSize); int stencilBackRef, bool frontFaceCCW, unsigned int stencilSize);
virtual void setScissorRectangle(const gl::Rectangle &scissor); virtual void setScissorRectangle(const gl::Rectangle &scissor);
virtual bool setViewport(const gl::Rectangle& viewport, float zNear, float zFar, virtual bool setViewport(const gl::Rectangle &viewport, float zNear, float zFar,
unsigned int renderTargetWidth, unsigned int renderTargetHeight,
gl::ProgramBinary *currentProgram, bool forceSetUniforms); gl::ProgramBinary *currentProgram, bool forceSetUniforms);
virtual bool applyRenderTarget(gl::Framebuffer *frameBuffer); virtual bool applyRenderTarget(gl::Framebuffer *frameBuffer);
......
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