Commit 70958d15 by Cody Northrop Committed by Commit Bot

Let attribute aliasing logic detect overflow

Checking against the max attribute count is not needed as aliasing is implemented correctly below. If not enough locations are available, linking will fail. This works for backends that support aliasing (Vulkan, GLES), but not for D3D11, which asserts. To handle this, add a limitation that informs the frontend of aliased attribute support. Bug: angleproject:3252 Bug: chromium:964404 Change-Id: Ib9ae5d381bbb2e6bf496272fc3d9e88467c17290 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1572817 Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent b16d69c3
...@@ -292,7 +292,8 @@ Limitations::Limitations() ...@@ -292,7 +292,8 @@ Limitations::Limitations()
shadersRequireIndexedLoopValidation(false), shadersRequireIndexedLoopValidation(false),
noSimultaneousConstantColorAndAlphaBlendFunc(false), noSimultaneousConstantColorAndAlphaBlendFunc(false),
noFlexibleVaryingPacking(false), noFlexibleVaryingPacking(false),
noDoubleBoundTransformFeedbackBuffers(false) noDoubleBoundTransformFeedbackBuffers(false),
noVertexAttributeAliasing(false)
{} {}
static bool GetFormatSupportBase(const TextureCapsMap &textureCaps, static bool GetFormatSupportBase(const TextureCapsMap &textureCaps,
......
...@@ -545,6 +545,9 @@ struct Limitations ...@@ -545,6 +545,9 @@ struct Limitations
// D3D does not support having multiple transform feedback outputs go to the same buffer. // D3D does not support having multiple transform feedback outputs go to the same buffer.
bool noDoubleBoundTransformFeedbackBuffers; bool noDoubleBoundTransformFeedbackBuffers;
// D3D does not support vertex attribute aliasing
bool noVertexAttributeAliasing;
}; };
struct TypePrecision struct TypePrecision
......
...@@ -1364,8 +1364,7 @@ angle::Result Program::link(const Context *context) ...@@ -1364,8 +1364,7 @@ angle::Result Program::link(const Context *context)
data.getCaps().maxVaryingVectors, packMode, &mState.mUniformBlocks, &mState.mUniforms, data.getCaps().maxVaryingVectors, packMode, &mState.mUniformBlocks, &mState.mUniforms,
&mState.mShaderStorageBlocks, &mState.mBufferVariables, &mState.mAtomicCounterBuffers)); &mState.mShaderStorageBlocks, &mState.mBufferVariables, &mState.mAtomicCounterBuffers));
if (!linkAttributes(context->getCaps(), mInfoLog, if (!linkAttributes(context, mInfoLog))
context->getExtensions().webglCompatibility))
{ {
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -3133,8 +3132,12 @@ bool Program::linkAtomicCounterBuffers() ...@@ -3133,8 +3132,12 @@ bool Program::linkAtomicCounterBuffers()
} }
// Assigns locations to all attributes from the bindings and program locations. // Assigns locations to all attributes from the bindings and program locations.
bool Program::linkAttributes(const Caps &caps, InfoLog &infoLog, bool webglCompatibility) bool Program::linkAttributes(const Context *context, InfoLog &infoLog)
{ {
const Caps &caps = context->getCaps();
const Limitations &limitations = context->getLimitations();
bool webglCompatibility = context->getExtensions().webglCompatibility;
Shader *vertexShader = mState.getAttachedShader(ShaderType::Vertex); Shader *vertexShader = mState.getAttachedShader(ShaderType::Vertex);
int shaderVersion = vertexShader->getShaderVersion(); int shaderVersion = vertexShader->getShaderVersion();
...@@ -3153,13 +3156,6 @@ bool Program::linkAttributes(const Caps &caps, InfoLog &infoLog, bool webglCompa ...@@ -3153,13 +3156,6 @@ bool Program::linkAttributes(const Caps &caps, InfoLog &infoLog, bool webglCompa
} }
GLuint maxAttribs = caps.maxVertexAttributes; GLuint maxAttribs = caps.maxVertexAttributes;
// TODO(jmadill): handle aliasing robustly
if (mState.mAttributes.size() > maxAttribs)
{
infoLog << "Too many vertex attributes.";
return false;
}
std::vector<sh::Attribute *> usedAttribMap(maxAttribs, nullptr); std::vector<sh::Attribute *> usedAttribMap(maxAttribs, nullptr);
// Assign locations to attributes that have a binding location and check for attribute aliasing. // Assign locations to attributes that have a binding location and check for attribute aliasing.
...@@ -3197,10 +3193,11 @@ bool Program::linkAttributes(const Caps &caps, InfoLog &infoLog, bool webglCompa ...@@ -3197,10 +3193,11 @@ bool Program::linkAttributes(const Caps &caps, InfoLog &infoLog, bool webglCompa
// In GLSL ES 3.00.6 and in WebGL, attribute aliasing produces a link error. // In GLSL ES 3.00.6 and in WebGL, attribute aliasing produces a link error.
// In non-WebGL GLSL ES 1.00.17, attribute aliasing is allowed with some // In non-WebGL GLSL ES 1.00.17, attribute aliasing is allowed with some
// restrictions - see GLSL ES 1.00.17 section 2.10.4, but ANGLE currently has a bug. // restrictions - see GLSL ES 1.00.17 section 2.10.4, but ANGLE currently has a bug.
// TODO: Remaining failures: http://anglebug.com/3252 // In D3D 9 and 11, aliasing is not supported, so check a limitation.
if (linkedAttribute) if (linkedAttribute)
{ {
if (shaderVersion >= 300 || webglCompatibility) if (shaderVersion >= 300 || webglCompatibility ||
limitations.noVertexAttributeAliasing)
{ {
infoLog << "Attribute '" << attribute.name << "' aliases attribute '" infoLog << "Attribute '" << attribute.name << "' aliases attribute '"
<< linkedAttribute->name << "' at location " << regLocation; << linkedAttribute->name << "' at location " << regLocation;
......
...@@ -910,7 +910,7 @@ class Program final : angle::NonCopyable, public LabeledObject ...@@ -910,7 +910,7 @@ class Program final : angle::NonCopyable, public LabeledObject
void deleteSelf(const Context *context); void deleteSelf(const Context *context);
bool linkValidateShaders(InfoLog &infoLog); bool linkValidateShaders(InfoLog &infoLog);
bool linkAttributes(const Caps &caps, InfoLog &infoLog, bool webglCompatibility); bool linkAttributes(const Context *context, InfoLog &infoLog);
bool linkInterfaceBlocks(const Caps &caps, bool linkInterfaceBlocks(const Caps &caps,
const Version &version, const Version &version,
bool webglCompatibility, bool webglCompatibility,
......
...@@ -1683,6 +1683,9 @@ void GenerateCaps(ID3D11Device *device, ...@@ -1683,6 +1683,9 @@ void GenerateCaps(ID3D11Device *device,
// D3D11 does not support multiple transform feedback outputs writing to the same buffer. // D3D11 does not support multiple transform feedback outputs writing to the same buffer.
limitations->noDoubleBoundTransformFeedbackBuffers = true; limitations->noDoubleBoundTransformFeedbackBuffers = true;
// D3D11 does not support vertex attribute aliasing
limitations->noVertexAttributeAliasing = true;
#ifdef ANGLE_ENABLE_WINDOWS_STORE #ifdef ANGLE_ENABLE_WINDOWS_STORE
// Setting a non-zero divisor on attribute zero doesn't work on certain Windows Phone 8-era // Setting a non-zero divisor on attribute zero doesn't work on certain Windows Phone 8-era
// devices. We should prevent developers from doing this on ALL Windows Store devices. This will // devices. We should prevent developers from doing this on ALL Windows Store devices. This will
......
...@@ -757,6 +757,9 @@ void GenerateCaps(IDirect3D9 *d3d9, ...@@ -757,6 +757,9 @@ void GenerateCaps(IDirect3D9 *d3d9,
// D3D9 cannot support packing more than one variable to a single varying. // D3D9 cannot support packing more than one variable to a single varying.
// TODO(jmadill): Implement more sophisticated component packing in D3D9. // TODO(jmadill): Implement more sophisticated component packing in D3D9.
limitations->noFlexibleVaryingPacking = true; limitations->noFlexibleVaryingPacking = true;
// D3D9 does not support vertex attribute aliasing
limitations->noVertexAttributeAliasing = true;
} }
} // namespace d3d9_gl } // namespace d3d9_gl
......
...@@ -74,9 +74,11 @@ ...@@ -74,9 +74,11 @@
1028 : dEQP-GLES2.functional.fbo.completeness.renderable.texture.stencil.srgb8 = FAIL 1028 : dEQP-GLES2.functional.fbo.completeness.renderable.texture.stencil.srgb8 = FAIL
1028 : dEQP-GLES2.functional.fbo.completeness.renderable.texture.depth.srgb8 = FAIL 1028 : dEQP-GLES2.functional.fbo.completeness.renderable.texture.depth.srgb8 = FAIL
// Bind aliasing max_cond crashes on Windows, fails on other platforms. // Vertex attribute aliasing is not supported on D3D
// TODO(cnorthrop): Narrow skip list or fix the test 3467 D3D9 : dEQP-GLES2.functional.attribute_location.bind_aliasing.cond* = FAIL
3252 : dEQP-GLES2.functional.attribute_location.bind_aliasing.max_cond* = SKIP 3467 D3D9 : dEQP-GLES2.functional.attribute_location.bind_aliasing.max_cond* = FAIL
3467 D3D11 : dEQP-GLES2.functional.attribute_location.bind_aliasing.cond* = FAIL
3467 D3D11 : dEQP-GLES2.functional.attribute_location.bind_aliasing.max_cond* = FAIL
// Half float OES either has an implementation bug or a dEQP bug. // Half float OES either has an implementation bug or a dEQP bug.
3283 : dEQP-GLES2.functional.fbo.completeness.renderable.texture.color0.rgba_half_float_oes = FAIL 3283 : dEQP-GLES2.functional.fbo.completeness.renderable.texture.color0.rgba_half_float_oes = FAIL
...@@ -171,6 +173,8 @@ ...@@ -171,6 +173,8 @@
3303 OPENGL NVIDIA LINUX : dEQP-GLES2.functional.texture.mipmap.cube.projected.nearest_linear = FAIL 3303 OPENGL NVIDIA LINUX : dEQP-GLES2.functional.texture.mipmap.cube.projected.nearest_linear = FAIL
// Mac OpenGL specific failures // Mac OpenGL specific failures
3466 MAC OPENGL : dEQP-GLES2.functional.attribute_location.bind_aliasing.cond* = SKIP
3466 MAC OPENGL : dEQP-GLES2.functional.attribute_location.bind_aliasing.max_cond* = SKIP
3433 MAC OPENGL : dEQP-GLES2.functional.shaders.preprocessor.pragmas.pragma_vertex = FAIL 3433 MAC OPENGL : dEQP-GLES2.functional.shaders.preprocessor.pragmas.pragma_vertex = FAIL
1143 MAC OPENGL : dEQP-GLES2.functional.shaders.scoping.valid.local_int_variable_hides_struct_type_* = FAIL 1143 MAC OPENGL : dEQP-GLES2.functional.shaders.scoping.valid.local_int_variable_hides_struct_type_* = FAIL
1143 MAC OPENGL : dEQP-GLES2.functional.shaders.scoping.valid.local_struct_variable_hides_struct_type_* = FAIL 1143 MAC OPENGL : dEQP-GLES2.functional.shaders.scoping.valid.local_struct_variable_hides_struct_type_* = FAIL
...@@ -251,6 +255,7 @@ ...@@ -251,6 +255,7 @@
// Nexus 5x failures // Nexus 5x failures
3309 NEXUS5X GLES : dEQP-GLES2.functional.attribute_location.bind_aliasing.cond* = FAIL 3309 NEXUS5X GLES : dEQP-GLES2.functional.attribute_location.bind_aliasing.cond* = FAIL
3309 NEXUS5X GLES : dEQP-GLES2.functional.attribute_location.bind_aliasing.max_cond* = FAIL
3309 NEXUS5X GLES : dEQP-GLES2.functional.fbo.render.texsubimage.after_render_tex2d_rgb = FAIL 3309 NEXUS5X GLES : dEQP-GLES2.functional.fbo.render.texsubimage.after_render_tex2d_rgb = FAIL
3309 NEXUS5X GLES : dEQP-GLES2.functional.polygon_offset.default_result_depth_clamp = FAIL 3309 NEXUS5X GLES : dEQP-GLES2.functional.polygon_offset.default_result_depth_clamp = FAIL
3309 NEXUS5X GLES : dEQP-GLES2.functional.shaders.return.output_write_in_func_always_vertex = FAIL 3309 NEXUS5X GLES : dEQP-GLES2.functional.shaders.return.output_write_in_func_always_vertex = FAIL
......
...@@ -110,9 +110,11 @@ ...@@ -110,9 +110,11 @@
// Failing everywhere // Failing everywhere
2322 : dEQP-GLES3.functional.shaders.metamorphic.* = FAIL 2322 : dEQP-GLES3.functional.shaders.metamorphic.* = FAIL
// Bind aliasing max_cond crashes on Windows, fails on other platforms. // Vertex attribute aliasing is not supported on D3D
// TODO(cnorthrop): Narrow skip list or fix the test 3467 D3D9 : dEQP-GLES3.functional.attribute_location.bind_aliasing.cond* = FAIL
3252 : dEQP-GLES3.functional.attribute_location.bind_aliasing.max_cond* = SKIP 3467 D3D9 : dEQP-GLES3.functional.attribute_location.bind_aliasing.max_cond* = FAIL
3467 D3D11 : dEQP-GLES3.functional.attribute_location.bind_aliasing.cond* = FAIL
3467 D3D11 : dEQP-GLES3.functional.attribute_location.bind_aliasing.max_cond* = FAIL
// Windows and Linux failures // Windows and Linux failures
1095 WIN : dEQP-GLES3.functional.texture.mipmap.2d.projected.* = FAIL 1095 WIN : dEQP-GLES3.functional.texture.mipmap.2d.projected.* = FAIL
...@@ -342,6 +344,8 @@ ...@@ -342,6 +344,8 @@
2349 LINUX OPENGL INTEL : dEQP-GLES3.functional.fbo.blit.default_framebuffer* = FAIL 2349 LINUX OPENGL INTEL : dEQP-GLES3.functional.fbo.blit.default_framebuffer* = FAIL
// Mac failures (overbroad suppresions) // Mac failures (overbroad suppresions)
3466 MAC OPENGL : dEQP-GLES3.functional.attribute_location.bind_aliasing.cond* = SKIP
3466 MAC OPENGL : dEQP-GLES3.functional.attribute_location.bind_aliasing.max_cond* = SKIP
2137 MAC OPENGL : dEQP-GLES3.functional.fbo.blit.default_framebuffer.* = FAIL 2137 MAC OPENGL : dEQP-GLES3.functional.fbo.blit.default_framebuffer.* = FAIL
2137 MAC OPENGL : dEQP-GLES3.functional.fbo.blit.rect.out_of_bounds_reverse_* = FAIL 2137 MAC OPENGL : dEQP-GLES3.functional.fbo.blit.rect.out_of_bounds_reverse_* = FAIL
2137 MAC OPENGL : dEQP-GLES3.functional.implementation_limits.compressed_texture_formats = FAIL 2137 MAC OPENGL : dEQP-GLES3.functional.implementation_limits.compressed_texture_formats = FAIL
...@@ -504,6 +508,7 @@ ...@@ -504,6 +508,7 @@
// Nexus 5x failures // Nexus 5x failures
3308 NEXUS5X GLES : dEQP-GLES3.functional.attribute_location.bind_aliasing.cond* = FAIL 3308 NEXUS5X GLES : dEQP-GLES3.functional.attribute_location.bind_aliasing.cond* = FAIL
3308 NEXUS5X GLES : dEQP-GLES3.functional.attribute_location.bind_aliasing.max_cond* = FAIL
3308 NEXUS5X GLES : dEQP-GLES3.functional.polygon_offset.default_result_depth_clamp = FAIL 3308 NEXUS5X GLES : dEQP-GLES3.functional.polygon_offset.default_result_depth_clamp = FAIL
3308 NEXUS5X GLES : dEQP-GLES3.functional.polygon_offset.fixed24_result_depth_clamp = FAIL 3308 NEXUS5X GLES : dEQP-GLES3.functional.polygon_offset.fixed24_result_depth_clamp = FAIL
3308 NEXUS5X GLES : dEQP-GLES3.functional.transform_feedback.random.interleaved.lines.3 = FAIL 3308 NEXUS5X GLES : dEQP-GLES3.functional.transform_feedback.random.interleaved.lines.3 = FAIL
......
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