Map renderer texture formats to OpenGL

This commit is contained in:
2026-06-02 18:14:40 +02:00
parent 8c99454bf5
commit dc03491b0d
5 changed files with 75 additions and 2 deletions

View File

@@ -144,6 +144,33 @@ void maps_image_channel_count_to_texture_format(pp::tests::Harness& h)
PP_EXPECT(h, invalid.pixel_format == 0U);
}
void maps_renderer_texture_formats_to_opengl_tokens(pp::tests::Harness& h)
{
const auto rgba8 = pp::renderer::gl::texture_format_for_renderer_format(pp::renderer::TextureFormat::rgba8);
const auto r8 = pp::renderer::gl::texture_format_for_renderer_format(pp::renderer::TextureFormat::r8);
const auto depth_stencil = pp::renderer::gl::texture_format_for_renderer_format(
pp::renderer::TextureFormat::depth24_stencil8);
const auto invalid = pp::renderer::gl::texture_format_for_renderer_format(
static_cast<pp::renderer::TextureFormat>(255U));
PP_EXPECT(h, rgba8.internal_format == 0x8058U);
PP_EXPECT(h, rgba8.pixel_format == 0x1908U);
PP_EXPECT(h, rgba8.component_type == 0x1401U);
PP_EXPECT(h, rgba8.bytes_per_pixel == 4U);
PP_EXPECT(h, r8.internal_format == 0x8229U);
PP_EXPECT(h, r8.pixel_format == 0x1903U);
PP_EXPECT(h, r8.component_type == 0x1401U);
PP_EXPECT(h, r8.bytes_per_pixel == 1U);
PP_EXPECT(h, depth_stencil.internal_format == 0x88F0U);
PP_EXPECT(h, depth_stencil.pixel_format == 0x84F9U);
PP_EXPECT(h, depth_stencil.component_type == 0x84FAU);
PP_EXPECT(h, depth_stencil.bytes_per_pixel == 4U);
PP_EXPECT(h, invalid.internal_format == 0U);
PP_EXPECT(h, invalid.pixel_format == 0U);
PP_EXPECT(h, invalid.component_type == 0U);
PP_EXPECT(h, invalid.bytes_per_pixel == 0U);
}
void maps_readback_formats(pp::tests::Harness& h)
{
const auto rgba8 = pp::renderer::gl::rgba8_readback_format();
@@ -512,6 +539,7 @@ int main()
harness.run("ignores_gles_texture_extensions_for_webgl_runtime", ignores_gles_texture_extensions_for_webgl_runtime);
harness.run("selects_texture_upload_type_from_internal_format", selects_texture_upload_type_from_internal_format);
harness.run("maps_image_channel_count_to_texture_format", maps_image_channel_count_to_texture_format);
harness.run("maps_renderer_texture_formats_to_opengl_tokens", maps_renderer_texture_formats_to_opengl_tokens);
harness.run("maps_readback_formats", maps_readback_formats);
harness.run("maps_pixel_buffer_parameters", maps_pixel_buffer_parameters);
harness.run("names_framebuffer_status_codes", names_framebuffer_status_codes);