mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 16:21:29 +00:00
LibSoftGPU: Only render complete primitives
Previously, we were expecting triangles and quads to consist of complete sets of vertices. However, a more common behavior is to ignore all vertices that do not make up a full primitive. For example, OpenGL specifies for `GL_QUADS`: "The total number of vertices between Begin and End is 4n + k, where 0 ≤ k ≤ 3; if k is not zero, the final k vertices are ignored." This changes the behavior of `Device::draw_primitives()` to both return early if no full set of vertices was provided, and to ignore any additional vertices that are not part of a full set.
This commit is contained in:
parent
69eb3b0838
commit
17ec433326
Notes:
sideshowbarker
2024-07-17 21:10:34 +09:00
Author: https://github.com/gmta Commit: https://github.com/SerenityOS/serenity/commit/17ec4333265 Pull-request: https://github.com/SerenityOS/serenity/pull/11800 Reviewed-by: https://github.com/Quaker762 Reviewed-by: https://github.com/linusg Reviewed-by: https://github.com/sunverwerth ✅
|
@ -568,7 +568,9 @@ void Device::draw_primitives(PrimitiveType primitive_type, FloatMatrix4x4 const&
|
|||
// Let's construct some triangles
|
||||
if (primitive_type == PrimitiveType::Triangles) {
|
||||
Triangle triangle;
|
||||
for (size_t i = 0; i < vertices.size(); i += 3) {
|
||||
if (vertices.size() < 3)
|
||||
return;
|
||||
for (size_t i = 0; i < vertices.size() - 2; i += 3) {
|
||||
triangle.vertices[0] = vertices.at(i);
|
||||
triangle.vertices[1] = vertices.at(i + 1);
|
||||
triangle.vertices[2] = vertices.at(i + 2);
|
||||
|
@ -578,8 +580,9 @@ void Device::draw_primitives(PrimitiveType primitive_type, FloatMatrix4x4 const&
|
|||
} else if (primitive_type == PrimitiveType::Quads) {
|
||||
// We need to construct two triangles to form the quad
|
||||
Triangle triangle;
|
||||
VERIFY(vertices.size() % 4 == 0);
|
||||
for (size_t i = 0; i < vertices.size(); i += 4) {
|
||||
if (vertices.size() < 4)
|
||||
return;
|
||||
for (size_t i = 0; i < vertices.size() - 3; i += 4) {
|
||||
// Triangle 1
|
||||
triangle.vertices[0] = vertices.at(i);
|
||||
triangle.vertices[1] = vertices.at(i + 1);
|
||||
|
|
Loading…
Reference in a new issue