Commit 7478ce7f by Qin Jiajia Committed by Commit Bot

D3D11: Minor Optimization to DrawCallNeedsTranslation

Remove IsStreamingIndexData from DrawCallNeedsTranslation since IsStreamingIndexData is only needed for drawElementsIndirect for fast path. This change gives about a 4% improvement on the drawElements benchmark for the D3D11 backend with the null driver. BUG=angleproject:1155 Change-Id: Ife2a9748f6b6fe9bc1f3a67c96672ab941a89d44 Reviewed-on: https://chromium-review.googlesource.com/717946Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 111a99e8
......@@ -224,7 +224,8 @@ gl::Error IndexDataManager::prepareIndexData(const gl::Context *context,
// We should never have to deal with MAX_UINT indices, since we restrict it via
// MAX_ELEMENT_INDEX.
ASSERT(!(mRendererClass == RENDERER_D3D11 && !primitiveRestartFixedIndexEnabled &&
hasPrimitiveRestartIndex && srcType == GL_UNSIGNED_INT));
(hasPrimitiveRestartIndex && translated->indexRange.vertexIndexCount != 0) &&
srcType == GL_UNSIGNED_INT));
const GLenum dstType = (srcType == GL_UNSIGNED_INT || primitiveRestartWorkaround)
? GL_UNSIGNED_INT
......
......@@ -358,7 +358,7 @@ void GetTriFanIndices(const void *indices,
}
}
bool DrawCallNeedsTranslation(const gl::Context *context, GLenum mode, GLenum type)
bool DrawCallNeedsTranslation(const gl::Context *context, GLenum mode)
{
const auto &glState = context->getGLState();
const auto &vertexArray = glState.getVertexArray();
......@@ -378,13 +378,6 @@ bool DrawCallNeedsTranslation(const gl::Context *context, GLenum mode, GLenum ty
return true;
}
if (type != GL_NONE)
{
// Only non-streaming index data can be directly used to draw since they don't
// need the indices and count informations.
return IndexDataManager::IsStreamingIndexData(context, type, RENDERER_D3D11);
}
return false;
}
......@@ -1664,21 +1657,20 @@ gl::Error Renderer11::drawElements(const gl::Context *context,
const gl::Program *program = glState.getProgram();
GLsizei adjustedInstanceCount = GetAdjustedInstanceCount(program, instances);
if (!DrawCallNeedsTranslation(context, mode, type))
if (!DrawCallNeedsTranslation(context, mode) &&
!IndexDataManager::UsePrimitiveRestartWorkaround(glState.isPrimitiveRestartEnabled(), type,
RENDERER_D3D11))
{
ANGLE_TRY(mStateManager.applyIndexBuffer(context, nullptr, 0, type, &indexInfo));
ANGLE_TRY(mStateManager.applyIndexBuffer(context, indices, count, type, &indexInfo));
ANGLE_TRY(mStateManager.applyVertexBuffer(context, mode, 0, 0, 0, &indexInfo));
const gl::Type &typeInfo = gl::GetTypeInfo(type);
unsigned int startIndexLocation =
static_cast<unsigned int>(reinterpret_cast<const uintptr_t>(indices)) / typeInfo.bytes;
if (adjustedInstanceCount > 0)
{
mDeviceContext->DrawIndexedInstanced(count, adjustedInstanceCount, startIndexLocation,
0, 0);
mDeviceContext->DrawIndexedInstanced(count, adjustedInstanceCount, 0, 0, 0);
}
else
{
mDeviceContext->DrawIndexed(count, startIndexLocation, 0);
mDeviceContext->DrawIndexed(count, 0, 0);
}
return gl::NoError();
}
......@@ -1771,7 +1763,7 @@ gl::Error Renderer11::drawArraysIndirect(const gl::Context *context,
Buffer11 *storage = GetImplAs<Buffer11>(drawIndirectBuffer);
uintptr_t offset = reinterpret_cast<uintptr_t>(indirect);
if (!DrawCallNeedsTranslation(context, mode, GL_NONE))
if (!DrawCallNeedsTranslation(context, mode))
{
ANGLE_TRY(mStateManager.applyVertexBuffer(context, mode, 0, 0, 0, nullptr));
ID3D11Buffer *buffer = nullptr;
......@@ -1823,7 +1815,8 @@ gl::Error Renderer11::drawElementsIndirect(const gl::Context *context,
uintptr_t offset = reinterpret_cast<uintptr_t>(indirect);
TranslatedIndexData indexInfo;
if (!DrawCallNeedsTranslation(context, mode, type))
if (!DrawCallNeedsTranslation(context, mode) &&
!IndexDataManager::IsStreamingIndexData(context, type, RENDERER_D3D11))
{
ANGLE_TRY(mStateManager.applyIndexBuffer(context, nullptr, 0, type, &indexInfo));
ANGLE_TRY(mStateManager.applyVertexBuffer(context, mode, 0, 0, 0, &indexInfo));
......
......@@ -158,10 +158,11 @@ void DrawElementsPerfBenchmark::drawBenchmark()
ASSERT_GL_NO_ERROR();
}
DrawElementsPerfParams DrawElementsPerfD3D11Params(bool indexBufferChanged)
DrawElementsPerfParams DrawElementsPerfD3D11Params(bool indexBufferChanged, bool useNullDevice)
{
DrawElementsPerfParams params;
params.eglParameters = angle::egl_platform::D3D11();
params.eglParameters =
useNullDevice ? angle::egl_platform::D3D11_NULL() : angle::egl_platform::D3D11();
params.indexBufferChanged = indexBufferChanged;
return params;
}
......@@ -190,8 +191,10 @@ TEST_P(DrawElementsPerfBenchmark, Run)
ANGLE_INSTANTIATE_TEST(DrawElementsPerfBenchmark,
DrawElementsPerfD3D9Params(false),
DrawElementsPerfD3D9Params(true),
DrawElementsPerfD3D11Params(false),
DrawElementsPerfD3D11Params(true),
DrawElementsPerfD3D11Params(false, true),
DrawElementsPerfD3D11Params(true, true),
DrawElementsPerfD3D11Params(false, false),
DrawElementsPerfD3D11Params(true, false),
DrawElementsPerfOpenGLParams(false),
DrawElementsPerfOpenGLParams(true));
......
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