From 39c449a763d50b0dbdce58f8bf253aeb2ecd4fab Mon Sep 17 00:00:00 2001 From: Roz K Date: Fri, 6 Jan 2023 18:16:10 +0100 Subject: [PATCH] Add direct copy when output and input vertex formats are matching. --- cpp/render/vertex_format_opengles.hpp | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/cpp/render/vertex_format_opengles.hpp b/cpp/render/vertex_format_opengles.hpp index 5656522..4b5247a 100644 --- a/cpp/render/vertex_format_opengles.hpp +++ b/cpp/render/vertex_format_opengles.hpp @@ -71,6 +71,20 @@ struct alignas(4) rk_output_row { } }; +template +struct alignas(4) rk_output_row<_output, _output, _cols, _signed, _normalized> { + rk_output<_output, _output, _signed, _normalized> output_col[_cols]; + + [[RK_FAST]] + inline void convert( + rk_input_row<_output, _cols> const & __restrict src) { + static_assert(sizeof(output_col) == sizeof(src.input_col)); + rk_output<_output, _output, _signed, _normalized> const * const input_col = + reinterpret_cast const *>(src.input_col); + *output_col = *input_col; + } +}; + template struct alignas(4) rk_output_row, _input, _cols, _signed, _normalized> { rk_output, _input, _signed, _normalized> output_cols; @@ -100,6 +114,20 @@ struct alignas(4) rk_output_format { } }; +template +struct alignas(4) rk_output_format<_output, _output, _cols, _rows, _signed, _normalized> { + rk_output_row<_output, _output, _cols, _signed, _normalized> output_row[_rows]; + + [[RK_FAST]] + inline void convert( + rk_input_format<_output, _cols, _rows> const & __restrict src) { + static_assert(sizeof(output_row) == sizeof(src.input_row)); + rk_output_row<_output, _output, _cols, _signed, _normalized> const * const input_row = + reinterpret_cast const *>(src.input_row); + *output_row = *input_row; + } +}; + template struct alignas(alignof(rk_packed<_signed, 3>)) rk_output, _input, _signed, _normalized> { rk_packed<_signed, 3> output;