Commit 95107bc8 by Jamie Madill Committed by Commit Bot

D3D11: Consolidate primitive topology application.

BUG=angleproject:2045 Change-Id: Ie1deac50a534ee748518d9ec5e6f749f3c78b53d Reviewed-on: https://chromium-review.googlesource.com/531795Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 6dd06eac
......@@ -1094,7 +1094,7 @@ gl::Error Blit11::swizzleTexture(const gl::Context *context,
// Apply shaders
stateManager->setInputLayout(support.inputLayout);
deviceContext->IASetPrimitiveTopology(topology);
stateManager->setPrimitiveTopology(topology);
deviceContext->VSSetShader(support.vertexShader, nullptr, 0);
deviceContext->PSSetShader(shader->pixelShader.get(), nullptr, 0);
......@@ -1229,7 +1229,7 @@ gl::Error Blit11::copyTexture(const gl::Context *context,
// Apply shaders
stateManager->setInputLayout(support.inputLayout);
deviceContext->IASetPrimitiveTopology(topology);
stateManager->setPrimitiveTopology(topology);
deviceContext->VSSetShader(support.vertexShader, nullptr, 0);
deviceContext->PSSetShader(shader->pixelShader.get(), nullptr, 0);
......@@ -1361,7 +1361,7 @@ gl::Error Blit11::copyDepth(const gl::Context *context,
// Apply shaders
stateManager->setInputLayout(&mQuad2DIL.getObj());
deviceContext->IASetPrimitiveTopology(topology);
stateManager->setPrimitiveTopology(topology);
deviceContext->VSSetShader(mQuad2DVS.get(), nullptr, 0);
deviceContext->PSSetShader(mDepthPS.get(), nullptr, 0);
......@@ -2020,7 +2020,7 @@ gl::ErrorOrResult<TextureHelper11> Blit11::resolveDepth(const gl::Context *conte
// Apply the necessary state changes to the D3D11 immediate device context.
stateManager->setInputLayout(nullptr);
deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
stateManager->setPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
deviceContext->VSSetShader(mResolveDepthStencilVS.get(), nullptr, 0);
deviceContext->GSSetShader(nullptr, nullptr, 0);
deviceContext->RSSetState(nullptr);
......@@ -2180,7 +2180,7 @@ gl::ErrorOrResult<TextureHelper11> Blit11::resolveStencil(const gl::Context *con
// Apply the necessary state changes to the D3D11 immediate device context.
stateManager->setInputLayout(nullptr);
deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
stateManager->setPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
deviceContext->VSSetShader(mResolveDepthStencilVS.get(), nullptr, 0);
deviceContext->GSSetShader(nullptr, nullptr, 0);
deviceContext->RSSetState(nullptr);
......
......@@ -707,7 +707,7 @@ gl::Error Clear11::clearFramebuffer(const gl::Context *context,
stateManager->setSingleVertexBuffer(nullptr, 0, 0);
}
deviceContext->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
stateManager->setPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
// Apply render targets
stateManager->setOneTimeRenderTargets(context, &rtvs[0], numRtvs, dsv);
......
......@@ -195,7 +195,7 @@ gl::Error PixelTransfer11::copyBufferToTexture(const gl::Context *context,
deviceContext->PSSetShader(pixelShader, nullptr, 0);
stateManager->setShaderResource(gl::SAMPLER_PIXEL, 0, bufferSRV);
stateManager->setInputLayout(nullptr);
deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
stateManager->setPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
stateManager->setSingleVertexBuffer(nullptr, 0, 0);
deviceContext->OMSetBlendState(nullptr, nullptr, 0xFFFFFFF);
......
......@@ -1713,11 +1713,7 @@ bool Renderer11::applyPrimitiveType(GLenum mode, GLsizei count, bool usesPointSi
primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
}
if (primitiveTopology != mCurrentPrimitiveTopology)
{
mDeviceContext->IASetPrimitiveTopology(primitiveTopology);
mCurrentPrimitiveTopology = primitiveTopology;
}
mStateManager.setPrimitiveTopology(primitiveTopology);
return count >= minCount;
}
......@@ -2789,8 +2785,6 @@ void Renderer11::markAllStateDirty(const gl::Context *context)
mCurrentPixelConstantBuffer = angle::DirtyPointer;
mCurrentGeometryConstantBuffer = angle::DirtyPointer;
mCurrentComputeConstantBuffer = angle::DirtyPointer;
mCurrentPrimitiveTopology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED;
}
void Renderer11::releaseDeviceResources()
......
......@@ -621,9 +621,6 @@ class Renderer11 : public RendererD3D
StateManager11 mStateManager;
// Currently applied primitive topology
D3D11_PRIMITIVE_TOPOLOGY mCurrentPrimitiveTopology;
// Currently applied index buffer
ID3D11Buffer *mAppliedIB;
DXGI_FORMAT mAppliedIBFormat;
......
......@@ -159,7 +159,8 @@ StateManager11::StateManager11(Renderer11 *renderer)
mDirtyCurrentValueAttribs(),
mCurrentValueAttribs(),
mCurrentInputLayout(),
mDirtyVertexBufferRange(gl::MAX_VERTEX_ATTRIBS, 0)
mDirtyVertexBufferRange(gl::MAX_VERTEX_ATTRIBS, 0),
mCurrentPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_UNDEFINED)
{
mCurBlendState.blend = false;
mCurBlendState.sourceBlendRGB = GL_ONE;
......@@ -845,6 +846,8 @@ void StateManager11::invalidateEverything(const gl::Context *context)
// Invalidate the vertex buffer state.
invalidateVertexBuffer();
mCurrentPrimitiveTopology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED;
}
void StateManager11::invalidateVertexBuffer()
......@@ -1282,4 +1285,13 @@ gl::Error StateManager11::updateState(const gl::Context *context, GLenum drawMod
return gl::NoError();
}
void StateManager11::setPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY primitiveTopology)
{
if (primitiveTopology != mCurrentPrimitiveTopology)
{
mRenderer->getDeviceContext()->IASetPrimitiveTopology(primitiveTopology);
mCurrentPrimitiveTopology = primitiveTopology;
}
}
} // namespace rx
......@@ -109,6 +109,8 @@ class StateManager11 final : angle::NonCopyable
gl::Error updateState(const gl::Context *context, GLenum drawMode);
void setPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY primitiveTopology);
private:
void unsetConflictingSRVs(gl::SamplerType shaderType,
uintptr_t resource,
......@@ -244,6 +246,9 @@ class StateManager11 final : angle::NonCopyable
std::array<UINT, gl::MAX_VERTEX_ATTRIBS> mCurrentVertexStrides;
std::array<UINT, gl::MAX_VERTEX_ATTRIBS> mCurrentVertexOffsets;
gl::RangeUI mDirtyVertexBufferRange;
// Currently applied primitive topology
D3D11_PRIMITIVE_TOPOLOGY mCurrentPrimitiveTopology;
};
} // namespace rx
......
......@@ -813,7 +813,7 @@ EGLint SwapChain11::copyOffscreenToBackbuffer(const gl::Context *context,
// Apply shaders
stateManager->setInputLayout(&mPassThroughIL);
deviceContext->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
stateManager->setPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
deviceContext->VSSetShader(mPassThroughVS.get(), nullptr, 0);
deviceContext->PSSetShader(mPassThroughPS.get(), nullptr, 0);
deviceContext->GSSetShader(nullptr, nullptr, 0);
......
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