Check OpenGL readback byte counts

This commit is contained in:
2026-06-02 18:09:45 +02:00
parent 0fc73d51d2
commit 8c99454bf5
4 changed files with 39 additions and 3 deletions

View File

@@ -5,6 +5,7 @@
#include <array>
#include <cstdint>
#include <cstring>
#include <limits>
#include <string_view>
namespace {
@@ -152,11 +153,30 @@ void maps_readback_formats(pp::tests::Harness& h)
PP_EXPECT(h, rgba8.component_type == 0x1401U);
PP_EXPECT(h, rgba8.bytes_per_pixel == 4U);
PP_EXPECT(h, pp::renderer::gl::readback_byte_count(rgba8, 3U, 5U) == 60U);
PP_EXPECT(h, pp::renderer::gl::readback_byte_count(rgba8, 0U, 5U) == 0U);
PP_EXPECT(h, rgba32f.pixel_format == 0x1908U);
PP_EXPECT(h, rgba32f.component_type == 0x1406U);
PP_EXPECT(h, rgba32f.bytes_per_pixel == 16U);
PP_EXPECT(h, pp::renderer::gl::readback_byte_count(rgba32f, 3U, 5U) == 240U);
const auto invalid_format = pp::renderer::gl::OpenGlReadbackFormat {
.pixel_format = rgba8.pixel_format,
.component_type = rgba8.component_type,
.bytes_per_pixel = 0U,
};
const auto overflowing_format = pp::renderer::gl::OpenGlReadbackFormat {
.pixel_format = rgba8.pixel_format,
.component_type = rgba8.component_type,
.bytes_per_pixel = std::numeric_limits<std::uint32_t>::max(),
};
PP_EXPECT(h, pp::renderer::gl::readback_byte_count(invalid_format, 1U, 1U) == 0U);
PP_EXPECT(h, pp::renderer::gl::readback_byte_count(
overflowing_format,
std::numeric_limits<std::uint32_t>::max(),
std::numeric_limits<std::uint32_t>::max())
== 0U);
}
void maps_pixel_buffer_parameters(pp::tests::Harness& h)