Route font mesh operations through renderer GL
This commit is contained in:
@@ -3059,6 +3059,76 @@ void creates_dynamic_mesh_without_initial_vertex_upload(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, recorded_vertex_array_bind_calls.size() == 3U);
|
||||
}
|
||||
|
||||
void creates_single_vertex_array_mesh_with_deferred_upload(pp::tests::Harness& h)
|
||||
{
|
||||
recorded_generated_buffer_counts.clear();
|
||||
recorded_generated_vertex_array_counts.clear();
|
||||
recorded_buffer_bind_calls.clear();
|
||||
recorded_buffer_data_calls.clear();
|
||||
recorded_vertex_array_bind_calls.clear();
|
||||
recorded_enabled_vertex_attributes.clear();
|
||||
recorded_vertex_attrib_pointer_calls.clear();
|
||||
next_buffer_id = 901U;
|
||||
next_vertex_array_id = 1001U;
|
||||
|
||||
constexpr std::array attributes {
|
||||
pp::renderer::gl::OpenGlVertexAttribute {
|
||||
.index = 0U,
|
||||
.component_count = 2,
|
||||
.component_type = 0x1406U,
|
||||
.normalized = 0U,
|
||||
.stride = 16,
|
||||
.offset = 0U,
|
||||
},
|
||||
pp::renderer::gl::OpenGlVertexAttribute {
|
||||
.index = 1U,
|
||||
.component_count = 2,
|
||||
.component_type = 0x1406U,
|
||||
.normalized = 0U,
|
||||
.stride = 16,
|
||||
.offset = 8U,
|
||||
},
|
||||
};
|
||||
|
||||
const auto mesh = pp::renderer::gl::create_opengl_mesh_objects(
|
||||
pp::renderer::gl::OpenGlMeshUpload {
|
||||
.vertex_data = nullptr,
|
||||
.vertex_byte_count = 0,
|
||||
.index_data = nullptr,
|
||||
.index_byte_count = 0,
|
||||
.indexed = true,
|
||||
.vertex_array_count = 1U,
|
||||
.attributes = attributes,
|
||||
},
|
||||
pp::renderer::gl::OpenGlMeshCreateDispatch {
|
||||
.gen_buffers = record_gen_buffers,
|
||||
.bind_buffer = record_bind_buffer,
|
||||
.buffer_data = record_buffer_data,
|
||||
.gen_vertex_arrays = record_gen_vertex_arrays,
|
||||
.bind_vertex_array = record_bind_vertex_array,
|
||||
.enable_vertex_attrib_array = record_enable_vertex_attrib_array,
|
||||
.vertex_attrib_pointer = record_vertex_attrib_pointer,
|
||||
});
|
||||
|
||||
PP_EXPECT(h, mesh.ok());
|
||||
PP_EXPECT(h, mesh.value().vertex_buffer == 901U);
|
||||
PP_EXPECT(h, mesh.value().index_buffer == 902U);
|
||||
PP_EXPECT(h, mesh.value().vertex_arrays[0] == 1001U);
|
||||
PP_EXPECT(h, mesh.value().vertex_arrays[1] == 0U);
|
||||
PP_EXPECT(h, recorded_generated_buffer_counts.size() == 1U);
|
||||
PP_EXPECT(h, recorded_generated_buffer_counts[0] == 2U);
|
||||
PP_EXPECT(h, recorded_generated_vertex_array_counts.size() == 1U);
|
||||
PP_EXPECT(h, recorded_generated_vertex_array_counts[0] == 1U);
|
||||
PP_EXPECT(h, recorded_buffer_data_calls.empty());
|
||||
PP_EXPECT(h, recorded_vertex_array_bind_calls.size() == 2U);
|
||||
PP_EXPECT(h, recorded_vertex_array_bind_calls[0] == 1001U);
|
||||
PP_EXPECT(h, recorded_vertex_array_bind_calls[1] == 0U);
|
||||
PP_EXPECT(h, recorded_enabled_vertex_attributes.size() == 2U);
|
||||
PP_EXPECT(h, recorded_vertex_attrib_pointer_calls.size() == 2U);
|
||||
PP_EXPECT(h, recorded_vertex_attrib_pointer_calls[0].index == 0U);
|
||||
PP_EXPECT(h, recorded_vertex_attrib_pointer_calls[1].offset == reinterpret_cast<const void*>(8U));
|
||||
}
|
||||
|
||||
void updates_draws_and_deletes_mesh_through_dispatch(pp::tests::Harness& h)
|
||||
{
|
||||
recorded_buffer_bind_calls.clear();
|
||||
@@ -3212,6 +3282,22 @@ void rejects_invalid_mesh_dispatch(pp::tests::Harness& h)
|
||||
.enable_vertex_attrib_array = record_enable_vertex_attrib_array,
|
||||
.vertex_attrib_pointer = record_vertex_attrib_pointer,
|
||||
});
|
||||
const auto invalid_vertex_array_count = pp::renderer::gl::create_opengl_mesh_objects(
|
||||
pp::renderer::gl::OpenGlMeshUpload {
|
||||
.vertex_data = vertices.data(),
|
||||
.vertex_byte_count = static_cast<std::intptr_t>(sizeof(float) * vertices.size()),
|
||||
.vertex_array_count = 3U,
|
||||
.attributes = attributes,
|
||||
},
|
||||
pp::renderer::gl::OpenGlMeshCreateDispatch {
|
||||
.gen_buffers = record_gen_buffers,
|
||||
.bind_buffer = record_bind_buffer,
|
||||
.buffer_data = record_buffer_data,
|
||||
.gen_vertex_arrays = record_gen_vertex_arrays,
|
||||
.bind_vertex_array = record_bind_vertex_array,
|
||||
.enable_vertex_attrib_array = record_enable_vertex_attrib_array,
|
||||
.vertex_attrib_pointer = record_vertex_attrib_pointer,
|
||||
});
|
||||
const auto missing_upload_dispatch = pp::renderer::gl::upload_opengl_buffer_data(
|
||||
pp::renderer::gl::OpenGlBufferUpload {
|
||||
.target = 0x8892U,
|
||||
@@ -3261,6 +3347,8 @@ void rejects_invalid_mesh_dispatch(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, invalid_create_data.status().code == pp::foundation::StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !invalid_attribute.ok());
|
||||
PP_EXPECT(h, invalid_attribute.status().code == pp::foundation::StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !invalid_vertex_array_count.ok());
|
||||
PP_EXPECT(h, invalid_vertex_array_count.status().code == pp::foundation::StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !missing_upload_dispatch.ok());
|
||||
PP_EXPECT(h, missing_upload_dispatch.code == pp::foundation::StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !invalid_upload.ok());
|
||||
@@ -4069,6 +4157,7 @@ int main()
|
||||
harness.run("rejects_invalid_uniform_discovery_dispatch", rejects_invalid_uniform_discovery_dispatch);
|
||||
harness.run("creates_indexed_mesh_objects_through_dispatch", creates_indexed_mesh_objects_through_dispatch);
|
||||
harness.run("creates_dynamic_mesh_without_initial_vertex_upload", creates_dynamic_mesh_without_initial_vertex_upload);
|
||||
harness.run("creates_single_vertex_array_mesh_with_deferred_upload", creates_single_vertex_array_mesh_with_deferred_upload);
|
||||
harness.run("updates_draws_and_deletes_mesh_through_dispatch", updates_draws_and_deletes_mesh_through_dispatch);
|
||||
harness.run("rejects_invalid_mesh_dispatch", rejects_invalid_mesh_dispatch);
|
||||
harness.run("updates_texture_2d_through_dispatch", updates_texture_2d_through_dispatch);
|
||||
|
||||
Reference in New Issue
Block a user