Commit 7ef2ddab by Jamie Madill Committed by Commit Bot

D3D11: Consolidate Viewport state application.

BUG=angleproject:2052 Change-Id: I1cbf2adc09c82b9de68785265def9361eff418b3 Reviewed-on: https://chromium-review.googlesource.com/659236Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 7f4fed80
...@@ -1105,14 +1105,7 @@ gl::Error Blit11::swizzleTexture(const gl::Context *context, ...@@ -1105,14 +1105,7 @@ gl::Error Blit11::swizzleTexture(const gl::Context *context,
stateManager->setRenderTarget(dest.get(), nullptr); stateManager->setRenderTarget(dest.get(), nullptr);
// Set the viewport // Set the viewport
D3D11_VIEWPORT viewport; stateManager->setSimpleViewport(size);
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = static_cast<FLOAT>(size.width);
viewport.Height = static_cast<FLOAT>(size.height);
viewport.MinDepth = 0.0f;
viewport.MaxDepth = 1.0f;
deviceContext->RSSetViewports(1, &viewport);
// Apply textures // Apply textures
stateManager->setShaderResource(gl::SAMPLER_PIXEL, 0, source.get()); stateManager->setShaderResource(gl::SAMPLER_PIXEL, 0, source.get());
...@@ -1238,14 +1231,7 @@ gl::Error Blit11::copyTexture(const gl::Context *context, ...@@ -1238,14 +1231,7 @@ gl::Error Blit11::copyTexture(const gl::Context *context,
stateManager->setRenderTarget(dest.get(), nullptr); stateManager->setRenderTarget(dest.get(), nullptr);
// Set the viewport // Set the viewport
D3D11_VIEWPORT viewport; stateManager->setSimpleViewport(destSize);
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = static_cast<FLOAT>(destSize.width);
viewport.Height = static_cast<FLOAT>(destSize.height);
viewport.MinDepth = 0.0f;
viewport.MaxDepth = 1.0f;
deviceContext->RSSetViewports(1, &viewport);
// Apply textures // Apply textures
stateManager->setShaderResource(gl::SAMPLER_PIXEL, 0, source.get()); stateManager->setShaderResource(gl::SAMPLER_PIXEL, 0, source.get());
...@@ -1368,14 +1354,7 @@ gl::Error Blit11::copyDepth(const gl::Context *context, ...@@ -1368,14 +1354,7 @@ gl::Error Blit11::copyDepth(const gl::Context *context,
stateManager->setRenderTarget(nullptr, dest.get()); stateManager->setRenderTarget(nullptr, dest.get());
// Set the viewport // Set the viewport
D3D11_VIEWPORT viewport; stateManager->setSimpleViewport(destSize);
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = static_cast<FLOAT>(destSize.width);
viewport.Height = static_cast<FLOAT>(destSize.height);
viewport.MinDepth = 0.0f;
viewport.MaxDepth = 1.0f;
deviceContext->RSSetViewports(1, &viewport);
// Apply textures // Apply textures
stateManager->setShaderResource(gl::SAMPLER_PIXEL, 0, source.get()); stateManager->setShaderResource(gl::SAMPLER_PIXEL, 0, source.get());
...@@ -2023,14 +2002,7 @@ gl::ErrorOrResult<TextureHelper11> Blit11::resolveDepth(const gl::Context *conte ...@@ -2023,14 +2002,7 @@ gl::ErrorOrResult<TextureHelper11> Blit11::resolveDepth(const gl::Context *conte
stateManager->setSimpleBlendState(nullptr); stateManager->setSimpleBlendState(nullptr);
// Set the viewport // Set the viewport
D3D11_VIEWPORT viewport; stateManager->setSimpleViewport(extents);
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = static_cast<FLOAT>(extents.width);
viewport.Height = static_cast<FLOAT>(extents.height);
viewport.MinDepth = 0.0f;
viewport.MaxDepth = 1.0f;
deviceContext->RSSetViewports(1, &viewport);
ID3D11ShaderResourceView *pixelViews[] = {depth->getShaderResourceView().get()}; ID3D11ShaderResourceView *pixelViews[] = {depth->getShaderResourceView().get()};
...@@ -2193,14 +2165,7 @@ gl::ErrorOrResult<TextureHelper11> Blit11::resolveStencil(const gl::Context *con ...@@ -2193,14 +2165,7 @@ gl::ErrorOrResult<TextureHelper11> Blit11::resolveStencil(const gl::Context *con
stateManager->setSimpleBlendState(nullptr); stateManager->setSimpleBlendState(nullptr);
// Set the viewport // Set the viewport
D3D11_VIEWPORT viewport; stateManager->setSimpleViewport(extents);
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = static_cast<FLOAT>(extents.width);
viewport.Height = static_cast<FLOAT>(extents.height);
viewport.MinDepth = 0.0f;
viewport.MaxDepth = 1.0f;
deviceContext->RSSetViewports(1, &viewport);
ID3D11ShaderResourceView *pixelViews[] = { ID3D11ShaderResourceView *pixelViews[] = {
depthStencil->getShaderResourceView().get(), mStencilSRV.get(), depthStencil->getShaderResourceView().get(), mStencilSRV.get(),
......
...@@ -764,14 +764,7 @@ gl::Error Clear11::clearFramebuffer(const gl::Context *context, ...@@ -764,14 +764,7 @@ gl::Error Clear11::clearFramebuffer(const gl::Context *context,
auto *stateManager = mRenderer->getStateManager(); auto *stateManager = mRenderer->getStateManager();
// Set the viewport to be the same size as the framebuffer. // Set the viewport to be the same size as the framebuffer.
D3D11_VIEWPORT viewport; stateManager->setSimpleViewport(framebufferSize);
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = static_cast<FLOAT>(framebufferSize.width);
viewport.Height = static_cast<FLOAT>(framebufferSize.height);
viewport.MinDepth = 0;
viewport.MaxDepth = 1;
deviceContext->RSSetViewports(1, &viewport);
// Apply state // Apply state
stateManager->setSimpleBlendState(blendState); stateManager->setSimpleBlendState(blendState);
......
...@@ -210,14 +210,7 @@ gl::Error PixelTransfer11::copyBufferToTexture(const gl::Context *context, ...@@ -210,14 +210,7 @@ gl::Error PixelTransfer11::copyBufferToTexture(const gl::Context *context,
stateManager->setVertexConstantBuffer(0, &mParamsConstantBuffer); stateManager->setVertexConstantBuffer(0, &mParamsConstantBuffer);
// Set the viewport // Set the viewport
D3D11_VIEWPORT viewport; stateManager->setSimpleViewport(destSize);
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = static_cast<FLOAT>(destSize.width);
viewport.Height = static_cast<FLOAT>(destSize.height);
viewport.MinDepth = 0.0f;
viewport.MaxDepth = 1.0f;
deviceContext->RSSetViewports(1, &viewport);
UINT numPixels = (destArea.width * destArea.height * destArea.depth); UINT numPixels = (destArea.width * destArea.height * destArea.depth);
deviceContext->Draw(numPixels, 0); deviceContext->Draw(numPixels, 0);
......
...@@ -2081,6 +2081,25 @@ void StateManager11::setRasterizerState(const d3d11::RasterizerState *rasterizer ...@@ -2081,6 +2081,25 @@ void StateManager11::setRasterizerState(const d3d11::RasterizerState *rasterizer
mInternalDirtyBits.set(DIRTY_BIT_RASTERIZER_STATE); mInternalDirtyBits.set(DIRTY_BIT_RASTERIZER_STATE);
} }
void StateManager11::setSimpleViewport(const gl::Extents &extents)
{
setSimpleViewport(extents.width, extents.height);
}
void StateManager11::setSimpleViewport(int width, int height)
{
D3D11_VIEWPORT viewport;
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = static_cast<FLOAT>(width);
viewport.Height = static_cast<FLOAT>(height);
viewport.MinDepth = 0.0f;
viewport.MaxDepth = 1.0f;
mRenderer->getDeviceContext()->RSSetViewports(1, &viewport);
mInternalDirtyBits.set(DIRTY_BIT_VIEWPORT_STATE);
}
// For each Direct3D sampler of either the pixel or vertex stage, // For each Direct3D sampler of either the pixel or vertex stage,
// looks up the corresponding OpenGL texture image unit and texture type, // looks up the corresponding OpenGL texture image unit and texture type,
// and sets the texture and its addressing/filtering state (or NULL when inactive). // and sets the texture and its addressing/filtering state (or NULL when inactive).
......
...@@ -214,6 +214,8 @@ class StateManager11 final : angle::NonCopyable ...@@ -214,6 +214,8 @@ class StateManager11 final : angle::NonCopyable
void setDepthStencilState(const d3d11::DepthStencilState *depthStencilState, UINT stencilRef); void setDepthStencilState(const d3d11::DepthStencilState *depthStencilState, UINT stencilRef);
void setSimpleBlendState(const d3d11::BlendState *blendState); void setSimpleBlendState(const d3d11::BlendState *blendState);
void setRasterizerState(const d3d11::RasterizerState *rasterizerState); void setRasterizerState(const d3d11::RasterizerState *rasterizerState);
void setSimpleViewport(const gl::Extents &viewportExtents);
void setSimpleViewport(int width, int height);
// Not handled by an internal dirty bit because of the extra draw parameters. // Not handled by an internal dirty bit because of the extra draw parameters.
gl::Error applyVertexBuffer(const gl::Context *context, gl::Error applyVertexBuffer(const gl::Context *context,
......
...@@ -840,14 +840,7 @@ EGLint SwapChain11::copyOffscreenToBackbuffer(const gl::Context *context, ...@@ -840,14 +840,7 @@ EGLint SwapChain11::copyOffscreenToBackbuffer(const gl::Context *context,
stateManager->setRenderTarget(mBackBufferRTView.get(), nullptr); stateManager->setRenderTarget(mBackBufferRTView.get(), nullptr);
// Set the viewport // Set the viewport
D3D11_VIEWPORT viewport; stateManager->setSimpleViewport(mWidth, mHeight);
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = static_cast<FLOAT>(mWidth);
viewport.Height = static_cast<FLOAT>(mHeight);
viewport.MinDepth = 0.0f;
viewport.MaxDepth = 1.0f;
deviceContext->RSSetViewports(1, &viewport);
// Apply textures // Apply textures
stateManager->setShaderResource(gl::SAMPLER_PIXEL, 0, mOffscreenSRView.get()); stateManager->setShaderResource(gl::SAMPLER_PIXEL, 0, mOffscreenSRView.get());
......
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