Add desktop GPU preview readback gate
This commit is contained in:
@@ -261,7 +261,7 @@ if(TARGET pp_renderer_gl)
|
||||
user32)
|
||||
endif()
|
||||
|
||||
add_test(NAME pp_renderer_gl_gpu_readback_tests COMMAND pp_renderer_gl_gpu_readback_tests)
|
||||
add_test(NAME pp_renderer_gl_gpu_readback_tests COMMAND $<TARGET_FILE:pp_renderer_gl_gpu_readback_tests>)
|
||||
set_tests_properties(pp_renderer_gl_gpu_readback_tests PROPERTIES
|
||||
LABELS "renderer;gpu"
|
||||
SKIP_REGULAR_EXPRESSION "\\[skip\\]")
|
||||
|
||||
@@ -175,11 +175,50 @@ void opengl_clear_readback_matches_fixture(pp::tests::Harness& h)
|
||||
#endif
|
||||
}
|
||||
|
||||
void opengl_preview_readback_matches_fixture(pp::tests::Harness& h)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
HiddenWglContext context;
|
||||
if (!context.ready()) {
|
||||
std::cout << "[skip] desktop GPU preview OpenGL readback unavailable: " << context.skip_reason() << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
glViewport(0, 0, 1, 1);
|
||||
glDrawBuffer(GL_BACK);
|
||||
glReadBuffer(GL_BACK);
|
||||
glClearColor(0.0F, 1.0F, 0.0F, 1.0F);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glFinish();
|
||||
|
||||
std::array<std::uint8_t, 4> pixel {};
|
||||
glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel.data());
|
||||
|
||||
constexpr std::array<std::uint8_t, 4> expected {
|
||||
0,
|
||||
255,
|
||||
0,
|
||||
255,
|
||||
};
|
||||
if (pixel != expected) {
|
||||
std::cout << "preview readback rgba: "
|
||||
<< static_cast<int>(pixel[0]) << ", "
|
||||
<< static_cast<int>(pixel[1]) << ", "
|
||||
<< static_cast<int>(pixel[2]) << ", "
|
||||
<< static_cast<int>(pixel[3]) << "\n";
|
||||
}
|
||||
PP_EXPECT(h, pixel == expected);
|
||||
#else
|
||||
std::cout << "[skip] desktop GPU preview OpenGL readback unavailable: no platform context helper\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
pp::tests::Harness harness;
|
||||
harness.run("opengl_clear_readback_matches_fixture", opengl_clear_readback_matches_fixture);
|
||||
harness.run("opengl_preview_readback_matches_fixture", opengl_preview_readback_matches_fixture);
|
||||
return harness.finish();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user