Move convert GL state into renderer backend

This commit is contained in:
2026-06-04 20:27:43 +02:00
parent 51601adf6d
commit 967a15f15f
8 changed files with 172 additions and 25 deletions

View File

@@ -17,6 +17,7 @@ struct RecordedOpenGlStateCall {
enable,
disable,
blend_func,
blend_equation,
blend_equation_separate,
};
@@ -254,6 +255,14 @@ void record_blend_func(std::uint32_t source_factor, std::uint32_t destination_fa
});
}
void record_blend_equation(std::uint32_t equation) noexcept
{
recorded_state_calls.push_back(RecordedOpenGlStateCall {
.kind = RecordedOpenGlStateCall::Kind::blend_equation,
.first = equation,
});
}
void record_blend_equation_separate(std::uint32_t color_equation, std::uint32_t alpha_equation) noexcept
{
recorded_state_calls.push_back(RecordedOpenGlStateCall {
@@ -1646,6 +1655,15 @@ void maps_app_initialization_parameters(pp::tests::Harness& h)
PP_EXPECT(h, initial_state.color_equation == 0x8006U);
PP_EXPECT(h, initial_state.alpha_equation == 0x8008U);
const auto convert_state = pp::renderer::gl::panopainter_convert_command_state();
PP_EXPECT(h, !convert_state.depth_test_enabled);
PP_EXPECT(h, convert_state.program_point_size_enabled);
PP_EXPECT(h, convert_state.depth_test_state == 0x0B71U);
PP_EXPECT(h, convert_state.program_point_size_state == 0x8642U);
PP_EXPECT(h, convert_state.source_color_factor == 0x0302U);
PP_EXPECT(h, convert_state.destination_color_factor == 0x0303U);
PP_EXPECT(h, convert_state.blend_equation == 0x8006U);
PP_EXPECT(h, pp::renderer::gl::rgba8_internal_format() == 0x8058U);
PP_EXPECT(h, pp::renderer::gl::rgba16f_internal_format() == 0x881AU);
PP_EXPECT(h, pp::renderer::gl::rgba32f_internal_format() == 0x8814U);
@@ -1698,6 +1716,44 @@ void rejects_incomplete_app_initialization_state_dispatch(pp::tests::Harness& h)
PP_EXPECT(h, status.code == pp::foundation::StatusCode::invalid_argument);
}
void applies_convert_command_state(pp::tests::Harness& h)
{
recorded_state_calls.clear();
const auto status = pp::renderer::gl::apply_panopainter_convert_command_state(
pp::renderer::gl::OpenGlConvertCommandStateDispatch {
.enable = record_enable,
.disable = record_disable,
.blend_func = record_blend_func,
.blend_equation = record_blend_equation,
});
PP_EXPECT(h, status.ok());
PP_EXPECT(h, recorded_state_calls.size() == 4U);
PP_EXPECT(h, recorded_state_calls[0].kind == RecordedOpenGlStateCall::Kind::disable);
PP_EXPECT(h, recorded_state_calls[0].first == 0x0B71U);
PP_EXPECT(h, recorded_state_calls[1].kind == RecordedOpenGlStateCall::Kind::enable);
PP_EXPECT(h, recorded_state_calls[1].first == 0x8642U);
PP_EXPECT(h, recorded_state_calls[2].kind == RecordedOpenGlStateCall::Kind::blend_func);
PP_EXPECT(h, recorded_state_calls[2].first == 0x0302U);
PP_EXPECT(h, recorded_state_calls[2].second == 0x0303U);
PP_EXPECT(h, recorded_state_calls[3].kind == RecordedOpenGlStateCall::Kind::blend_equation);
PP_EXPECT(h, recorded_state_calls[3].first == 0x8006U);
}
void rejects_incomplete_convert_command_state_dispatch(pp::tests::Harness& h)
{
const auto status = pp::renderer::gl::apply_panopainter_convert_command_state(
pp::renderer::gl::OpenGlConvertCommandStateDispatch {
.enable = record_enable,
.disable = record_disable,
.blend_func = record_blend_func,
});
PP_EXPECT(h, !status.ok());
PP_EXPECT(h, status.code == pp::foundation::StatusCode::invalid_argument);
}
void snapshots_legacy_gl_state(pp::tests::Harness& h)
{
recorded_integer_queries.clear();
@@ -4354,6 +4410,8 @@ int main()
harness.run("maps_app_initialization_parameters", maps_app_initialization_parameters);
harness.run("applies_app_initialization_state", applies_app_initialization_state);
harness.run("rejects_incomplete_app_initialization_state_dispatch", rejects_incomplete_app_initialization_state_dispatch);
harness.run("applies_convert_command_state", applies_convert_command_state);
harness.run("rejects_incomplete_convert_command_state_dispatch", rejects_incomplete_convert_command_state_dispatch);
harness.run("snapshots_legacy_gl_state", snapshots_legacy_gl_state);
harness.run("rejects_incomplete_gl_state_snapshot_dispatch", rejects_incomplete_gl_state_snapshot_dispatch);
harness.run("restores_legacy_gl_state", restores_legacy_gl_state);