Route framebuffer texture copies through GL backend
This commit is contained in:
@@ -55,6 +55,17 @@ struct RecordedOpenGlTextureImageCall {
|
||||
bool sub_image = false;
|
||||
};
|
||||
|
||||
struct RecordedOpenGlFramebufferTextureCopyCall {
|
||||
std::uint32_t target = 0;
|
||||
std::int32_t level = 0;
|
||||
std::int32_t destination_x = 0;
|
||||
std::int32_t destination_y = 0;
|
||||
std::int32_t source_x = 0;
|
||||
std::int32_t source_y = 0;
|
||||
std::int32_t width = 0;
|
||||
std::int32_t height = 0;
|
||||
};
|
||||
|
||||
struct RecordedOpenGlFramebufferAttachmentCall {
|
||||
std::uint32_t target = 0;
|
||||
std::uint32_t attachment = 0;
|
||||
@@ -186,6 +197,7 @@ std::vector<RecordedOpenGlBindingCall> recorded_binding_calls;
|
||||
std::vector<std::uint32_t> recorded_generated_texture_counts;
|
||||
std::vector<std::uint32_t> recorded_deleted_textures;
|
||||
std::vector<RecordedOpenGlTextureImageCall> recorded_texture_image_calls;
|
||||
std::vector<RecordedOpenGlFramebufferTextureCopyCall> recorded_framebuffer_texture_copy_calls;
|
||||
std::vector<std::uint32_t> recorded_mipmap_targets;
|
||||
std::vector<std::uint32_t> recorded_generated_framebuffer_counts;
|
||||
std::vector<std::uint32_t> recorded_deleted_framebuffers;
|
||||
@@ -524,6 +536,28 @@ void record_tex_sub_image_2d(
|
||||
});
|
||||
}
|
||||
|
||||
void record_copy_tex_sub_image_2d(
|
||||
std::uint32_t target,
|
||||
std::int32_t level,
|
||||
std::int32_t destination_x,
|
||||
std::int32_t destination_y,
|
||||
std::int32_t source_x,
|
||||
std::int32_t source_y,
|
||||
std::int32_t width,
|
||||
std::int32_t height) noexcept
|
||||
{
|
||||
recorded_framebuffer_texture_copy_calls.push_back(RecordedOpenGlFramebufferTextureCopyCall {
|
||||
.target = target,
|
||||
.level = level,
|
||||
.destination_x = destination_x,
|
||||
.destination_y = destination_y,
|
||||
.source_x = source_x,
|
||||
.source_y = source_y,
|
||||
.width = width,
|
||||
.height = height,
|
||||
});
|
||||
}
|
||||
|
||||
void record_generate_mipmap(std::uint32_t target) noexcept
|
||||
{
|
||||
recorded_mipmap_targets.push_back(target);
|
||||
@@ -3775,6 +3809,76 @@ void updates_texture_2d_through_dispatch(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, recorded_texture_image_calls[0].data == pixels.data());
|
||||
}
|
||||
|
||||
void copies_framebuffer_to_texture_2d_through_dispatch(pp::tests::Harness& h)
|
||||
{
|
||||
recorded_framebuffer_texture_copy_calls.clear();
|
||||
|
||||
const auto status = pp::renderer::gl::copy_opengl_framebuffer_to_texture_2d(
|
||||
pp::renderer::gl::OpenGlTexture2DFramebufferCopy {
|
||||
.level = 1,
|
||||
.destination_x = 2,
|
||||
.destination_y = 3,
|
||||
.source_x = 4,
|
||||
.source_y = 5,
|
||||
.width = 6,
|
||||
.height = 7,
|
||||
},
|
||||
pp::renderer::gl::OpenGlTexture2DFramebufferCopyDispatch {
|
||||
.copy_tex_sub_image_2d = record_copy_tex_sub_image_2d,
|
||||
});
|
||||
|
||||
PP_EXPECT(h, status.ok());
|
||||
PP_EXPECT(h, recorded_framebuffer_texture_copy_calls.size() == 1U);
|
||||
PP_EXPECT(h, recorded_framebuffer_texture_copy_calls[0].target == 0x0DE1U);
|
||||
PP_EXPECT(h, recorded_framebuffer_texture_copy_calls[0].level == 1);
|
||||
PP_EXPECT(h, recorded_framebuffer_texture_copy_calls[0].destination_x == 2);
|
||||
PP_EXPECT(h, recorded_framebuffer_texture_copy_calls[0].destination_y == 3);
|
||||
PP_EXPECT(h, recorded_framebuffer_texture_copy_calls[0].source_x == 4);
|
||||
PP_EXPECT(h, recorded_framebuffer_texture_copy_calls[0].source_y == 5);
|
||||
PP_EXPECT(h, recorded_framebuffer_texture_copy_calls[0].width == 6);
|
||||
PP_EXPECT(h, recorded_framebuffer_texture_copy_calls[0].height == 7);
|
||||
}
|
||||
|
||||
void skips_zero_sized_framebuffer_to_texture_copies(pp::tests::Harness& h)
|
||||
{
|
||||
recorded_framebuffer_texture_copy_calls.clear();
|
||||
|
||||
const auto status = pp::renderer::gl::copy_opengl_framebuffer_to_texture_2d(
|
||||
pp::renderer::gl::OpenGlTexture2DFramebufferCopy {
|
||||
.width = 0,
|
||||
.height = 5,
|
||||
},
|
||||
pp::renderer::gl::OpenGlTexture2DFramebufferCopyDispatch {
|
||||
.copy_tex_sub_image_2d = record_copy_tex_sub_image_2d,
|
||||
});
|
||||
|
||||
PP_EXPECT(h, status.ok());
|
||||
PP_EXPECT(h, recorded_framebuffer_texture_copy_calls.empty());
|
||||
}
|
||||
|
||||
void rejects_invalid_framebuffer_to_texture_copies(pp::tests::Harness& h)
|
||||
{
|
||||
const auto missing_dispatch = pp::renderer::gl::copy_opengl_framebuffer_to_texture_2d(
|
||||
pp::renderer::gl::OpenGlTexture2DFramebufferCopy {
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
},
|
||||
pp::renderer::gl::OpenGlTexture2DFramebufferCopyDispatch {});
|
||||
const auto invalid_dimensions = pp::renderer::gl::copy_opengl_framebuffer_to_texture_2d(
|
||||
pp::renderer::gl::OpenGlTexture2DFramebufferCopy {
|
||||
.width = -1,
|
||||
.height = 1,
|
||||
},
|
||||
pp::renderer::gl::OpenGlTexture2DFramebufferCopyDispatch {
|
||||
.copy_tex_sub_image_2d = record_copy_tex_sub_image_2d,
|
||||
});
|
||||
|
||||
PP_EXPECT(h, !missing_dispatch.ok());
|
||||
PP_EXPECT(h, missing_dispatch.code == pp::foundation::StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !invalid_dimensions.ok());
|
||||
PP_EXPECT(h, invalid_dimensions.code == pp::foundation::StatusCode::invalid_argument);
|
||||
}
|
||||
|
||||
void generates_texture_2d_mipmaps_through_dispatch(pp::tests::Harness& h)
|
||||
{
|
||||
recorded_binding_calls.clear();
|
||||
@@ -4656,6 +4760,9 @@ int main()
|
||||
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);
|
||||
harness.run("copies_framebuffer_to_texture_2d_through_dispatch", copies_framebuffer_to_texture_2d_through_dispatch);
|
||||
harness.run("skips_zero_sized_framebuffer_to_texture_copies", skips_zero_sized_framebuffer_to_texture_copies);
|
||||
harness.run("rejects_invalid_framebuffer_to_texture_copies", rejects_invalid_framebuffer_to_texture_copies);
|
||||
harness.run("generates_texture_2d_mipmaps_through_dispatch", generates_texture_2d_mipmaps_through_dispatch);
|
||||
harness.run("reads_back_texture_2d_through_framebuffer_dispatch", reads_back_texture_2d_through_framebuffer_dispatch);
|
||||
harness.run("reports_incomplete_texture_2d_readback_framebuffer", reports_incomplete_texture_2d_readback_framebuffer);
|
||||
|
||||
Reference in New Issue
Block a user