Commit 9349e262 by shrekshao Committed by Commit Bot

Fix multiDraw* with DYNAMIC_DRAW buffer usage

Specialized Context11 impl to prevent promote Dynamic during MultiDraw. Add different buffer usage to MultiDraw and BaseVertexBaseInstance tests. Bug: angleproject:3402, angleproject:4754 Change-Id: I50e1a6fd6c8b6fd48f130c43545b895335d2e55b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2268581 Commit-Queue: Shrek Shao <shrekshao@google.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 796df76c
......@@ -265,7 +265,7 @@ angle::Result Context11::drawArrays(const gl::Context *context,
{
ASSERT(count > 0);
ANGLE_TRY(mRenderer->getStateManager()->updateState(
context, mode, first, count, gl::DrawElementsType::InvalidEnum, nullptr, 0, 0, 0));
context, mode, first, count, gl::DrawElementsType::InvalidEnum, nullptr, 0, 0, 0, true));
return mRenderer->drawArrays(context, mode, first, count, 0, 0);
}
......@@ -278,7 +278,7 @@ angle::Result Context11::drawArraysInstanced(const gl::Context *context,
ASSERT(count > 0);
ANGLE_TRY(mRenderer->getStateManager()->updateState(context, mode, first, count,
gl::DrawElementsType::InvalidEnum, nullptr,
instanceCount, 0, 0));
instanceCount, 0, 0, true));
return mRenderer->drawArrays(context, mode, first, count, instanceCount, 0);
}
......@@ -292,7 +292,7 @@ angle::Result Context11::drawArraysInstancedBaseInstance(const gl::Context *cont
ASSERT(count > 0);
ANGLE_TRY(mRenderer->getStateManager()->updateState(context, mode, first, count,
gl::DrawElementsType::InvalidEnum, nullptr,
instanceCount, 0, baseInstance));
instanceCount, 0, baseInstance, true));
return mRenderer->drawArrays(context, mode, first, count, instanceCount, baseInstance);
}
......@@ -303,7 +303,8 @@ ANGLE_INLINE angle::Result Context11::drawElementsImpl(const gl::Context *contex
const void *indices,
GLsizei instanceCount,
GLint baseVertex,
GLuint baseInstance)
GLuint baseInstance,
bool promoteDynamic)
{
ASSERT(indexCount > 0);
......@@ -315,9 +316,9 @@ ANGLE_INLINE angle::Result Context11::drawElementsImpl(const gl::Context *contex
GLint startVertex;
ANGLE_TRY(ComputeStartVertex(GetImplAs<Context11>(context), indexRange, baseVertex,
&startVertex));
ANGLE_TRY(mRenderer->getStateManager()->updateState(context, mode, startVertex, indexCount,
indexType, indices, instanceCount,
baseVertex, baseInstance));
ANGLE_TRY(mRenderer->getStateManager()->updateState(
context, mode, startVertex, indexCount, indexType, indices, instanceCount, baseVertex,
baseInstance, promoteDynamic));
return mRenderer->drawElements(context, mode, startVertex, indexCount, indexType, indices,
instanceCount, baseVertex, baseInstance);
}
......@@ -325,7 +326,7 @@ ANGLE_INLINE angle::Result Context11::drawElementsImpl(const gl::Context *contex
{
ANGLE_TRY(mRenderer->getStateManager()->updateState(context, mode, 0, indexCount, indexType,
indices, instanceCount, baseVertex,
baseInstance));
baseInstance, promoteDynamic));
return mRenderer->drawElements(context, mode, 0, indexCount, indexType, indices,
instanceCount, baseVertex, baseInstance);
}
......@@ -337,7 +338,7 @@ angle::Result Context11::drawElements(const gl::Context *context,
gl::DrawElementsType type,
const void *indices)
{
return drawElementsImpl(context, mode, count, type, indices, 0, 0, 0);
return drawElementsImpl(context, mode, count, type, indices, 0, 0, 0, true);
}
angle::Result Context11::drawElementsBaseVertex(const gl::Context *context,
......@@ -347,7 +348,7 @@ angle::Result Context11::drawElementsBaseVertex(const gl::Context *context,
const void *indices,
GLint baseVertex)
{
return drawElementsImpl(context, mode, count, type, indices, 0, baseVertex, 0);
return drawElementsImpl(context, mode, count, type, indices, 0, baseVertex, 0, true);
}
angle::Result Context11::drawElementsInstanced(const gl::Context *context,
......@@ -357,7 +358,7 @@ angle::Result Context11::drawElementsInstanced(const gl::Context *context,
const void *indices,
GLsizei instances)
{
return drawElementsImpl(context, mode, count, type, indices, instances, 0, 0);
return drawElementsImpl(context, mode, count, type, indices, instances, 0, 0, true);
}
angle::Result Context11::drawElementsInstancedBaseVertex(const gl::Context *context,
......@@ -368,7 +369,7 @@ angle::Result Context11::drawElementsInstancedBaseVertex(const gl::Context *cont
GLsizei instances,
GLint baseVertex)
{
return drawElementsImpl(context, mode, count, type, indices, instances, baseVertex, 0);
return drawElementsImpl(context, mode, count, type, indices, instances, baseVertex, 0, true);
}
angle::Result Context11::drawElementsInstancedBaseVertexBaseInstance(const gl::Context *context,
......@@ -381,7 +382,7 @@ angle::Result Context11::drawElementsInstancedBaseVertexBaseInstance(const gl::C
GLuint baseInstance)
{
return drawElementsImpl(context, mode, count, type, indices, instances, baseVertex,
baseInstance);
baseInstance, true);
}
angle::Result Context11::drawRangeElements(const gl::Context *context,
......@@ -392,7 +393,7 @@ angle::Result Context11::drawRangeElements(const gl::Context *context,
gl::DrawElementsType type,
const void *indices)
{
return drawElementsImpl(context, mode, count, type, indices, 0, 0, 0);
return drawElementsImpl(context, mode, count, type, indices, 0, 0, 0, true);
}
angle::Result Context11::drawRangeElementsBaseVertex(const gl::Context *context,
......@@ -404,7 +405,7 @@ angle::Result Context11::drawRangeElementsBaseVertex(const gl::Context *context,
const void *indices,
GLint baseVertex)
{
return drawElementsImpl(context, mode, count, type, indices, 0, baseVertex, 0);
return drawElementsImpl(context, mode, count, type, indices, 0, baseVertex, 0, true);
}
angle::Result Context11::drawArraysIndirect(const gl::Context *context,
......@@ -416,16 +417,16 @@ angle::Result Context11::drawArraysIndirect(const gl::Context *context,
const gl::DrawArraysIndirectCommand *cmd = nullptr;
ANGLE_TRY(ReadbackIndirectBuffer(context, indirect, &cmd));
ANGLE_TRY(mRenderer->getStateManager()->updateState(context, mode, cmd->first, cmd->count,
gl::DrawElementsType::InvalidEnum,
nullptr, cmd->instanceCount, 0, 0));
ANGLE_TRY(mRenderer->getStateManager()->updateState(
context, mode, cmd->first, cmd->count, gl::DrawElementsType::InvalidEnum, nullptr,
cmd->instanceCount, 0, 0, true));
return mRenderer->drawArrays(context, mode, cmd->first, cmd->count, cmd->instanceCount,
cmd->baseInstance);
}
else
{
ANGLE_TRY(mRenderer->getStateManager()->updateState(
context, mode, 0, 0, gl::DrawElementsType::InvalidEnum, nullptr, 0, 0, 0));
context, mode, 0, 0, gl::DrawElementsType::InvalidEnum, nullptr, 0, 0, 0, true));
return mRenderer->drawArraysIndirect(context, indirect);
}
}
......@@ -456,27 +457,96 @@ angle::Result Context11::drawElementsIndirect(const gl::Context *context,
ANGLE_TRY(ComputeStartVertex(GetImplAs<Context11>(context), indexRange, cmd->baseVertex,
&startVertex));
ANGLE_TRY(mRenderer->getStateManager()->updateState(context, mode, startVertex, cmd->count,
type, indices, cmd->primCount,
cmd->baseVertex, cmd->baseInstance));
ANGLE_TRY(mRenderer->getStateManager()->updateState(
context, mode, startVertex, cmd->count, type, indices, cmd->primCount, cmd->baseVertex,
cmd->baseInstance, true));
return mRenderer->drawElements(context, mode, static_cast<GLint>(indexRange.start),
cmd->count, type, indices, cmd->primCount, 0, 0);
}
else
{
ANGLE_TRY(
mRenderer->getStateManager()->updateState(context, mode, 0, 0, type, nullptr, 0, 0, 0));
ANGLE_TRY(mRenderer->getStateManager()->updateState(context, mode, 0, 0, type, nullptr, 0,
0, 0, true));
return mRenderer->drawElementsIndirect(context, indirect);
}
}
#define DRAW_ARRAYS__ \
{ \
ANGLE_TRY(mRenderer->getStateManager()->updateState( \
context, mode, firsts[drawID], counts[drawID], gl::DrawElementsType::InvalidEnum, \
nullptr, 0, 0, 0, false)); \
ANGLE_TRY(mRenderer->drawArrays(context, mode, firsts[drawID], counts[drawID], 0, 0)); \
}
#define DRAW_ARRAYS_INSTANCED_ \
{ \
ANGLE_TRY(mRenderer->getStateManager()->updateState( \
context, mode, firsts[drawID], counts[drawID], gl::DrawElementsType::InvalidEnum, \
nullptr, instanceCounts[drawID], 0, 0, false)); \
ANGLE_TRY(mRenderer->drawArrays(context, mode, firsts[drawID], counts[drawID], \
instanceCounts[drawID], 0)); \
}
#define DRAW_ARRAYS_INSTANCED_BASE_INSTANCE \
{ \
ANGLE_TRY(mRenderer->getStateManager()->updateState( \
context, mode, firsts[drawID], counts[drawID], gl::DrawElementsType::InvalidEnum, \
nullptr, instanceCounts[drawID], 0, baseInstances[drawID], false)); \
ANGLE_TRY(mRenderer->drawArrays(context, mode, firsts[drawID], counts[drawID], \
instanceCounts[drawID], baseInstances[drawID])); \
}
#define DRAW_ELEMENTS__ \
{ \
ANGLE_TRY(drawElementsImpl(context, mode, counts[drawID], type, indices[drawID], 0, 0, 0, \
false)); \
}
#define DRAW_ELEMENTS_INSTANCED_ \
{ \
ANGLE_TRY(drawElementsImpl(context, mode, counts[drawID], type, indices[drawID], \
instanceCounts[drawID], 0, 0, false)); \
}
#define DRAW_ELEMENTS_INSTANCED_BASE_VERTEX_BASE_INSTANCE \
{ \
ANGLE_TRY(drawElementsImpl(context, mode, counts[drawID], type, indices[drawID], \
instanceCounts[drawID], baseVertices[drawID], \
baseInstances[drawID], false)); \
}
#define DRAW_CALL(drawType, instanced, bvbi) DRAW_##drawType##instanced##bvbi
#define MULTI_DRAW_BLOCK(drawType, instanced, bvbi, hasDrawID, hasBaseVertex, hasBaseInstance) \
for (GLsizei drawID = 0; drawID < drawcount; ++drawID) \
{ \
if (ANGLE_NOOP_DRAW(instanced)) \
{ \
continue; \
} \
ANGLE_SET_DRAW_ID_UNIFORM(hasDrawID)(drawID); \
ANGLE_SET_BASE_VERTEX_UNIFORM(hasBaseVertex)(baseVertices[drawID]); \
ANGLE_SET_BASE_INSTANCE_UNIFORM(hasBaseInstance)(baseInstances[drawID]); \
ASSERT(counts[drawID] > 0); \
DRAW_CALL(drawType, instanced, bvbi); \
ANGLE_MARK_TRANSFORM_FEEDBACK_USAGE(instanced); \
gl::MarkShaderStorageBufferUsage(context); \
}
angle::Result Context11::multiDrawArrays(const gl::Context *context,
gl::PrimitiveMode mode,
const GLint *firsts,
const GLsizei *counts,
GLsizei drawcount)
{
return rx::MultiDrawArraysGeneral(this, context, mode, firsts, counts, drawcount);
gl::Program *programObject = context->getState().getLinkedProgram(context);
const bool hasDrawID = programObject && programObject->hasDrawIDUniform();
if (hasDrawID)
{
MULTI_DRAW_BLOCK(ARRAYS, _, _, 1, 0, 0)
}
else
{
MULTI_DRAW_BLOCK(ARRAYS, _, _, 0, 0, 0)
}
return angle::Result::Continue;
}
angle::Result Context11::multiDrawArraysInstanced(const gl::Context *context,
......@@ -486,8 +556,18 @@ angle::Result Context11::multiDrawArraysInstanced(const gl::Context *context,
const GLsizei *instanceCounts,
GLsizei drawcount)
{
return rx::MultiDrawArraysInstancedGeneral(this, context, mode, firsts, counts, instanceCounts,
drawcount);
gl::Program *programObject = context->getState().getLinkedProgram(context);
const bool hasDrawID = programObject && programObject->hasDrawIDUniform();
if (hasDrawID)
{
MULTI_DRAW_BLOCK(ARRAYS, _INSTANCED, _, 1, 0, 0)
}
else
{
MULTI_DRAW_BLOCK(ARRAYS, _INSTANCED, _, 0, 0, 0)
}
return angle::Result::Continue;
}
angle::Result Context11::multiDrawElements(const gl::Context *context,
......@@ -497,7 +577,18 @@ angle::Result Context11::multiDrawElements(const gl::Context *context,
const GLvoid *const *indices,
GLsizei drawcount)
{
return rx::MultiDrawElementsGeneral(this, context, mode, counts, type, indices, drawcount);
gl::Program *programObject = context->getState().getLinkedProgram(context);
const bool hasDrawID = programObject && programObject->hasDrawIDUniform();
if (hasDrawID)
{
MULTI_DRAW_BLOCK(ELEMENTS, _, _, 1, 0, 0)
}
else
{
MULTI_DRAW_BLOCK(ELEMENTS, _, _, 0, 0, 0)
}
return angle::Result::Continue;
}
angle::Result Context11::multiDrawElementsInstanced(const gl::Context *context,
......@@ -508,8 +599,18 @@ angle::Result Context11::multiDrawElementsInstanced(const gl::Context *context,
const GLsizei *instanceCounts,
GLsizei drawcount)
{
return rx::MultiDrawElementsInstancedGeneral(this, context, mode, counts, type, indices,
instanceCounts, drawcount);
gl::Program *programObject = context->getState().getLinkedProgram(context);
const bool hasDrawID = programObject && programObject->hasDrawIDUniform();
if (hasDrawID)
{
MULTI_DRAW_BLOCK(ELEMENTS, _INSTANCED, _, 1, 0, 0)
}
else
{
MULTI_DRAW_BLOCK(ELEMENTS, _INSTANCED, _, 0, 0, 0)
}
return angle::Result::Continue;
}
angle::Result Context11::multiDrawArraysInstancedBaseInstance(const gl::Context *context,
......@@ -520,8 +621,29 @@ angle::Result Context11::multiDrawArraysInstancedBaseInstance(const gl::Context
const GLuint *baseInstances,
GLsizei drawcount)
{
return rx::MultiDrawArraysInstancedBaseInstanceGeneral(
this, context, mode, firsts, counts, instanceCounts, baseInstances, drawcount);
gl::Program *programObject = context->getState().getLinkedProgram(context);
const bool hasDrawID = programObject && programObject->hasDrawIDUniform();
const bool hasBaseInstance = programObject && programObject->hasBaseInstanceUniform();
ResetBaseVertexBaseInstance resetUniforms(programObject, false, hasBaseInstance);
if (hasDrawID && hasBaseInstance)
{
MULTI_DRAW_BLOCK(ARRAYS, _INSTANCED, _BASE_INSTANCE, 1, 0, 1)
}
else if (hasDrawID)
{
MULTI_DRAW_BLOCK(ARRAYS, _INSTANCED, _BASE_INSTANCE, 1, 0, 0)
}
else if (hasBaseInstance)
{
MULTI_DRAW_BLOCK(ARRAYS, _INSTANCED, _BASE_INSTANCE, 0, 0, 1)
}
else
{
MULTI_DRAW_BLOCK(ARRAYS, _INSTANCED, _BASE_INSTANCE, 0, 0, 0)
}
return angle::Result::Continue;
}
angle::Result Context11::multiDrawElementsInstancedBaseVertexBaseInstance(
......@@ -535,9 +657,64 @@ angle::Result Context11::multiDrawElementsInstancedBaseVertexBaseInstance(
const GLuint *baseInstances,
GLsizei drawcount)
{
return rx::MultiDrawElementsInstancedBaseVertexBaseInstanceGeneral(
this, context, mode, counts, type, indices, instanceCounts, baseVertices, baseInstances,
drawcount);
gl::Program *programObject = context->getState().getLinkedProgram(context);
const bool hasDrawID = programObject && programObject->hasDrawIDUniform();
const bool hasBaseVertex = programObject && programObject->hasBaseVertexUniform();
const bool hasBaseInstance = programObject && programObject->hasBaseInstanceUniform();
ResetBaseVertexBaseInstance resetUniforms(programObject, hasBaseVertex, hasBaseInstance);
if (hasDrawID)
{
if (hasBaseVertex)
{
if (hasBaseInstance)
{
MULTI_DRAW_BLOCK(ELEMENTS, _INSTANCED, _BASE_VERTEX_BASE_INSTANCE, 1, 1, 1)
}
else
{
MULTI_DRAW_BLOCK(ELEMENTS, _INSTANCED, _BASE_VERTEX_BASE_INSTANCE, 1, 1, 0)
}
}
else
{
if (hasBaseInstance)
{
MULTI_DRAW_BLOCK(ELEMENTS, _INSTANCED, _BASE_VERTEX_BASE_INSTANCE, 1, 0, 1)
}
else
{
MULTI_DRAW_BLOCK(ELEMENTS, _INSTANCED, _BASE_VERTEX_BASE_INSTANCE, 1, 0, 0)
}
}
}
else
{
if (hasBaseVertex)
{
if (hasBaseInstance)
{
MULTI_DRAW_BLOCK(ELEMENTS, _INSTANCED, _BASE_VERTEX_BASE_INSTANCE, 0, 1, 1)
}
else
{
MULTI_DRAW_BLOCK(ELEMENTS, _INSTANCED, _BASE_VERTEX_BASE_INSTANCE, 0, 1, 0)
}
}
else
{
if (hasBaseInstance)
{
MULTI_DRAW_BLOCK(ELEMENTS, _INSTANCED, _BASE_VERTEX_BASE_INSTANCE, 0, 0, 1)
}
else
{
MULTI_DRAW_BLOCK(ELEMENTS, _INSTANCED, _BASE_VERTEX_BASE_INSTANCE, 0, 0, 0)
}
}
}
return angle::Result::Continue;
}
gl::GraphicsResetStatus Context11::getResetStatus()
......
......@@ -260,7 +260,8 @@ class Context11 : public ContextD3D, public MultisampleTextureInitializer
const void *indices,
GLsizei instanceCount,
GLint baseVertex,
GLuint baseInstance);
GLuint baseInstance,
bool promoteDynamic);
Renderer11 *mRenderer;
IncompleteTextureSet mIncompleteTextures;
......
......@@ -2169,7 +2169,8 @@ angle::Result StateManager11::updateState(const gl::Context *context,
const void *indices,
GLsizei instanceCount,
GLint baseVertex,
GLuint baseInstance)
GLuint baseInstance,
bool promoteDynamic)
{
const gl::State &glState = context->getState();
......@@ -2213,7 +2214,7 @@ angle::Result StateManager11::updateState(const gl::Context *context,
ANGLE_TRY(mVertexArray11->syncStateForDraw(context, firstVertex, vertexOrIndexCount,
indexTypeOrInvalid, indices, instanceCount,
baseVertex, baseInstance));
baseVertex, baseInstance, promoteDynamic));
// Changes in the draw call can affect the vertex buffer translations.
if (!mLastFirstVertex.valid() || mLastFirstVertex.value() != firstVertex)
......
......@@ -240,7 +240,8 @@ class StateManager11 final : angle::NonCopyable
const void *indices,
GLsizei instanceCount,
GLint baseVertex,
GLuint baseInstance);
GLuint baseInstance,
bool promoteDynamic);
void setShaderResourceShared(gl::ShaderType shaderType,
UINT resourceSlot,
......
......@@ -128,7 +128,8 @@ angle::Result VertexArray11::syncStateForDraw(const gl::Context *context,
const void *indices,
GLsizei instances,
GLint baseVertex,
GLuint baseInstance)
GLuint baseInstance,
bool promoteDynamic)
{
Renderer11 *renderer = GetImplAs<Context11>(context)->getRenderer();
StateManager11 *stateManager = renderer->getStateManager();
......@@ -161,7 +162,7 @@ angle::Result VertexArray11::syncStateForDraw(const gl::Context *context,
ANGLE_TRY(updateDynamicAttribs(context, stateManager->getVertexDataManager(),
firstVertex, vertexOrIndexCount, indexTypeOrInvalid,
indices, instances, baseVertex, baseInstance,
activeDynamicAttribs));
promoteDynamic, activeDynamicAttribs));
stateManager->invalidateInputLayout();
}
}
......@@ -295,6 +296,7 @@ angle::Result VertexArray11::updateDynamicAttribs(const gl::Context *context,
GLsizei instances,
GLint baseVertex,
GLuint baseInstance,
bool promoteDynamic,
const gl::AttributesMask &activeDynamicAttribs)
{
const auto &glState = context->getState();
......@@ -322,8 +324,11 @@ angle::Result VertexArray11::updateDynamicAttribs(const gl::Context *context,
activeDynamicAttribs, startVertex, vertexCount,
instances, baseInstance));
VertexDataManager::PromoteDynamicAttribs(context, mTranslatedAttribs, activeDynamicAttribs,
vertexCount);
if (promoteDynamic)
{
VertexDataManager::PromoteDynamicAttribs(context, mTranslatedAttribs, activeDynamicAttribs,
vertexCount);
}
return angle::Result::Continue;
}
......
......@@ -40,7 +40,8 @@ class VertexArray11 : public VertexArrayImpl
const void *indices,
GLsizei instances,
GLint baseVertex,
GLuint baseInstance);
GLuint baseInstance,
bool promoteDynamic);
// This will check the dynamic attribs mask.
bool hasActiveDynamicAttrib(const gl::Context *context);
......@@ -74,6 +75,7 @@ class VertexArray11 : public VertexArrayImpl
GLsizei instances,
GLint baseVertex,
GLuint baseInstance,
bool promoteDynamic,
const gl::AttributesMask &activeDynamicAttribs);
angle::Result updateElementArrayStorage(const gl::Context *context,
......
......@@ -359,14 +359,14 @@ void main()
void doDrawArraysBaseInstanceReset()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDrawArrays(GL_TRIANGLES, 0, 6 * kCountY);
glDrawArraysInstanced(GL_TRIANGLES, 0, 6 * kCountY, 1);
}
void doDrawElementsBaseVertexBaseInstanceReset()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDrawElements(GL_TRIANGLES, 6 * kCountY, GL_UNSIGNED_SHORT,
reinterpret_cast<GLvoid *>(static_cast<uintptr_t>(0)));
glDrawElementsInstanced(GL_TRIANGLES, 6 * kCountY, GL_UNSIGNED_SHORT,
reinterpret_cast<GLvoid *>(static_cast<uintptr_t>(0)), 1);
}
void doMultiDrawElementsInstancedBaseVertexBaseInstance()
......@@ -582,6 +582,7 @@ TEST_P(DrawBaseVertexBaseInstanceTest, DrawArraysInstancedBaseInstance)
checkDrawResult(false);
doDrawArraysBaseInstanceReset();
EXPECT_GL_NO_ERROR();
checkDrawResult(false, true);
}
......@@ -598,7 +599,6 @@ TEST_P(DrawBaseVertexBaseInstanceTest, MultiDrawArraysInstancedBaseInstance)
}
ANGLE_SKIP_TEST_IF(!requestExtensions());
ANGLE_SKIP_TEST_IF(getBufferDataUsage() == GL_DYNAMIC_DRAW);
GLProgram program;
setupProgram(program, true, true);
......@@ -619,6 +619,7 @@ TEST_P(DrawBaseVertexBaseInstanceTest, MultiDrawArraysInstancedBaseInstance)
checkDrawResult(false);
doDrawArraysBaseInstanceReset();
EXPECT_GL_NO_ERROR();
checkDrawResult(false, true);
}
......@@ -656,7 +657,6 @@ TEST_P(DrawBaseVertexBaseInstanceTest, DrawElementsInstancedBaseVertexBaseInstan
TEST_P(DrawBaseVertexBaseInstanceTest, MultiDrawElementsInstancedBaseVertexBaseInstance)
{
ANGLE_SKIP_TEST_IF(!requestExtensions());
ANGLE_SKIP_TEST_IF(getBufferDataUsage() == GL_DYNAMIC_DRAW);
GLProgram program;
setupProgram(program, false, true);
......
......@@ -62,7 +62,14 @@ enum class InstancingOption
UseInstancing,
};
using MultiDrawTestParams = std::tuple<angle::PlatformParameters, DrawIDOption, InstancingOption>;
enum class BufferDataUsageOption
{
StaticDraw,
DynamicDraw
};
using MultiDrawTestParams =
std::tuple<angle::PlatformParameters, DrawIDOption, InstancingOption, BufferDataUsageOption>;
struct PrintToStringParamName
{
......@@ -70,6 +77,8 @@ struct PrintToStringParamName
{
::std::stringstream ss;
ss << std::get<0>(info.param)
<< (std::get<3>(info.param) == BufferDataUsageOption::StaticDraw ? "__StaticDraw"
: "__DynamicDraw")
<< (std::get<2>(info.param) == InstancingOption::UseInstancing ? "__Instanced" : "")
<< (std::get<1>(info.param) == DrawIDOption::UseDrawID ? "__DrawID" : "");
return ss.str();
......@@ -111,6 +120,12 @@ class MultiDrawTest : public ANGLETestBase, public ::testing::TestWithParam<Mult
return std::get<2>(GetParam()) == InstancingOption::UseInstancing;
}
GLenum getBufferDataUsage() const
{
return std::get<3>(GetParam()) == BufferDataUsageOption::StaticDraw ? GL_STATIC_DRAW
: GL_DYNAMIC_DRAW;
}
std::string VertexShaderSource()
{
......@@ -216,22 +231,22 @@ void main()
glGenBuffers(1, &mNonIndexedVertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, mNonIndexedVertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * mNonIndexedVertices.size(),
mNonIndexedVertices.data(), GL_STATIC_DRAW);
mNonIndexedVertices.data(), getBufferDataUsage());
glGenBuffers(1, &mVertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, mVertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * mVertices.size(), mVertices.data(),
GL_STATIC_DRAW);
getBufferDataUsage());
glGenBuffers(1, &mIndexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLushort) * mIndices.size(), mIndices.data(),
GL_STATIC_DRAW);
getBufferDataUsage());
glGenBuffers(1, &mInstanceBuffer);
glBindBuffer(GL_ARRAY_BUFFER, mInstanceBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * instances.size(), instances.data(),
GL_STATIC_DRAW);
getBufferDataUsage());
ASSERT_GL_NO_ERROR();
}
......@@ -515,19 +530,21 @@ const angle::PlatformParameters es2_platforms[] = {
INSTANTIATE_TEST_SUITE_P(
,
MultiDrawTest,
testing::Combine(testing::ValuesIn(::angle::FilterTestParams(platforms, ArraySize(platforms))),
testing::Values(DrawIDOption::NoDrawID, DrawIDOption::UseDrawID),
testing::Values(InstancingOption::NoInstancing,
InstancingOption::UseInstancing)),
testing::Combine(
testing::ValuesIn(::angle::FilterTestParams(platforms, ArraySize(platforms))),
testing::Values(DrawIDOption::NoDrawID, DrawIDOption::UseDrawID),
testing::Values(InstancingOption::NoInstancing, InstancingOption::UseInstancing),
testing::Values(BufferDataUsageOption::StaticDraw, BufferDataUsageOption::DynamicDraw)),
PrintToStringParamName());
INSTANTIATE_TEST_SUITE_P(
,
MultiDrawNoInstancingSupportTest,
testing::Combine(testing::ValuesIn(::angle::FilterTestParams(es2_platforms,
ArraySize(es2_platforms))),
testing::Values(DrawIDOption::NoDrawID, DrawIDOption::UseDrawID),
testing::Values(InstancingOption::UseInstancing)),
testing::Combine(
testing::ValuesIn(::angle::FilterTestParams(es2_platforms, ArraySize(es2_platforms))),
testing::Values(DrawIDOption::NoDrawID, DrawIDOption::UseDrawID),
testing::Values(InstancingOption::UseInstancing),
testing::Values(BufferDataUsageOption::StaticDraw, BufferDataUsageOption::DynamicDraw)),
PrintToStringParamName());
} // namespace
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