Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
++
  • Loading branch information
jonahwilliams committed Jan 23, 2024
commit 6118426653976b62e811beec55b48565eec9c9a4
10 changes: 6 additions & 4 deletions impeller/entity/geometry/vertices_geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ GeometryResult VerticesGeometry::GetPositionColorBuffer(
size_t i = 0u;
auto vertex_buffer = renderer.GetTransientsBuffer().Emplace(
total_vtx_bytes, alignof(VS::PerVertexData), [&](uint8_t* data) {
VS::PerVertexData* vertex_data =
VS::PerVertexData* vtx_contents =
reinterpret_cast<VS::PerVertexData*>(data);
vertex_data[i] = {
VS::PerVertexData vertex_data = {
.position = vertices_[i],
.color = colors_[i],
};
i++;
std::memcpy(vtx_contents++, &vertex_data, sizeof(VS::PerVertexData));
});

BufferView index_buffer = {};
Expand Down Expand Up @@ -206,21 +207,22 @@ GeometryResult VerticesGeometry::GetPositionUVBuffer(
size_t i = 0u;
auto vertex_buffer = renderer.GetTransientsBuffer().Emplace(
total_vtx_bytes, alignof(VS::PerVertexData), [&](uint8_t* data) {
VS::PerVertexData* vertex_data =
VS::PerVertexData* vtx_contents =
reinterpret_cast<VS::PerVertexData*>(data);
auto vertex = vertices_[i];
auto texture_coord =
has_texture_coordinates ? texture_coordinates_[i] : vertices_[i];
auto uv = uv_transform * texture_coord;
// From experimentation we need to clamp these values to < 1.0 or else
// there can be flickering.
vertex_data[i] = {
VS::PerVertexData vertex_data = {
.position = vertex,
.texture_coords =
Point(std::clamp(uv.x, 0.0f, 1.0f - kEhCloseEnough),
std::clamp(uv.y, 0.0f, 1.0f - kEhCloseEnough)),
};
i++;
std::memcpy(vtx_contents++, &vertex_data, sizeof(VS::PerVertexData));
});

BufferView index_buffer = {};
Expand Down