From 431250d5bde35bc70b4148da7ed07a87f626f9ab Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Thu, 1 Nov 2018 18:19:44 +0700 Subject: [PATCH] add pvrtc v2 --- headers/enduro2d/core/render.hpp | 5 ++- sources/enduro2d/core/render.cpp | 37 ++++++++++--------- .../enduro2d/core/render_impl/render_none.cpp | 26 +++++++++++-- .../core/render_impl/render_opengl.cpp | 3 ++ .../core/render_impl/render_opengl_base.cpp | 6 +++ 5 files changed, 56 insertions(+), 21 deletions(-) diff --git a/headers/enduro2d/core/render.hpp b/headers/enduro2d/core/render.hpp index 78cb829a..ba09eab1 100644 --- a/headers/enduro2d/core/render.hpp +++ b/headers/enduro2d/core/render.hpp @@ -63,7 +63,10 @@ namespace e2d rgb_pvrtc4, rgba_pvrtc2, - rgba_pvrtc4 + rgba_pvrtc4, + + rgba_pvrtc2_v2, + rgba_pvrtc4_v2 }; static const char* pixel_type_to_cstr(pixel_type pt) noexcept; public: diff --git a/sources/enduro2d/core/render.cpp b/sources/enduro2d/core/render.cpp index 40c85c1f..fee1e42d 100644 --- a/sources/enduro2d/core/render.cpp +++ b/sources/enduro2d/core/render.cpp @@ -12,35 +12,38 @@ namespace struct pixel_type_description { const char* cstr; - u32 minimal_size; u32 bits_per_pixel; bool color; bool depth; bool stencil; pixel_declaration::pixel_type type; bool compressed; - bool must_be_square; - bool must_be_power_of_two; }; const pixel_type_description pixel_type_descriptions[] = { - {"depth16", 1, 16, false, true, false, pixel_declaration::pixel_type::depth16, false, false, false}, - {"depth24", 1, 24, false, true, false, pixel_declaration::pixel_type::depth24, false, false, false}, - {"depth32", 1, 32, false, true, false, pixel_declaration::pixel_type::depth32, false, false, false}, - {"depth24_stencil8", 1, 32, false, true, true, pixel_declaration::pixel_type::depth24_stencil8, false, false, false}, + {"depth16", 16, false, true, false, pixel_declaration::pixel_type::depth16, false}, + {"depth24", 24, false, true, false, pixel_declaration::pixel_type::depth24, false}, + {"depth32", 32, false, true, false, pixel_declaration::pixel_type::depth32, false}, + {"depth24_stencil8", 32, false, true, true, pixel_declaration::pixel_type::depth24_stencil8, false}, - {"rgb8", 1, 24, true, false, false, pixel_declaration::pixel_type::rgb8, false, false, false}, - {"rgba8", 1, 32, true, false, false, pixel_declaration::pixel_type::rgba8, false, false, false}, + {"rgb8", 24, true, false, false, pixel_declaration::pixel_type::rgb8, false}, + {"rgba8", 32, true, false, false, pixel_declaration::pixel_type::rgba8, false}, - {"rgb_dxt1", 4, 4, true, false, false, pixel_declaration::pixel_type::rgb_dxt1, true, false, true}, - {"rgba_dxt1", 4, 4, true, false, false, pixel_declaration::pixel_type::rgba_dxt1, true, false, true}, - {"rgba_dxt3", 4, 8, true, false, false, pixel_declaration::pixel_type::rgba_dxt3, true, false, true}, - {"rgba_dxt5", 4, 8, true, false, false, pixel_declaration::pixel_type::rgba_dxt5, true, false, true}, + {"rgb_dxt1", 4, true, false, false, pixel_declaration::pixel_type::rgb_dxt1, true}, + {"rgba_dxt1", 4, true, false, false, pixel_declaration::pixel_type::rgba_dxt1, true}, + {"rgba_dxt3", 8, true, false, false, pixel_declaration::pixel_type::rgba_dxt3, true}, + {"rgba_dxt5", 8, true, false, false, pixel_declaration::pixel_type::rgba_dxt5, true}, - {"rgb_pvrtc2", 8, 2, true, false, false, pixel_declaration::pixel_type::rgb_pvrtc2, true, true, true}, - {"rgb_pvrtc4", 8, 4, true, false, false, pixel_declaration::pixel_type::rgb_pvrtc4, true, true, true}, - {"rgba_pvrtc2", 8, 2, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc2, true, true, true}, - {"rgba_pvrtc4", 8, 4, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc4, true, true, true} + {"rgb_pvrtc2", 2, true, false, false, pixel_declaration::pixel_type::rgb_pvrtc2, true}, + {"rgb_pvrtc4", 4, true, false, false, pixel_declaration::pixel_type::rgb_pvrtc4, true}, + {"rgba_pvrtc2", 2, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc2, true}, + {"rgba_pvrtc4", 4, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc4, true}, + + {"rgba_pvrtc2", 2, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc2, true}, + {"rgba_pvrtc4", 4, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc4, true}, + + {"rgba_pvrtc2_v2", 2, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc2_v2, true}, + {"rgba_pvrtc4_v2", 4, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc4_v2, true} }; const pixel_type_description& get_pixel_type_description(pixel_declaration::pixel_type type) noexcept { diff --git a/sources/enduro2d/core/render_impl/render_none.cpp b/sources/enduro2d/core/render_impl/render_none.cpp index ef2a7b98..9eb58809 100644 --- a/sources/enduro2d/core/render_impl/render_none.cpp +++ b/sources/enduro2d/core/render_impl/render_none.cpp @@ -238,14 +238,34 @@ namespace e2d return *this; } + render& render::execute(const target_command& command) { + E2D_UNUSED(command); + return *this; + } + render& render::execute(const viewport_command& command) { E2D_UNUSED(command); return *this; } - render& render::execute(const render_target_command& command) { - E2D_UNUSED(command); - return *this; + const render::device_caps& render::device_capabilities() const noexcept { + static device_caps caps; + return caps; + } + + bool render::is_pixel_supported(const pixel_declaration& decl) const noexcept { + E2D_UNUSED(decl); + return false; + } + + bool render::is_index_supported(const index_declaration& decl) const noexcept { + E2D_UNUSED(decl); + return false; + } + + bool render::is_vertex_supported(const vertex_declaration& decl) const noexcept { + E2D_UNUSED(decl); + return false; } } diff --git a/sources/enduro2d/core/render_impl/render_opengl.cpp b/sources/enduro2d/core/render_impl/render_opengl.cpp index 44bbc4a3..84e66af6 100644 --- a/sources/enduro2d/core/render_impl/render_opengl.cpp +++ b/sources/enduro2d/core/render_impl/render_opengl.cpp @@ -1006,6 +1006,9 @@ namespace e2d case pixel_declaration::pixel_type::rgba_pvrtc2: case pixel_declaration::pixel_type::rgba_pvrtc4: return __GLEW_IMG_texture_compression_pvrtc; + case pixel_declaration::pixel_type::rgba_pvrtc2_v2: + case pixel_declaration::pixel_type::rgba_pvrtc4_v2: + return __GLEW_IMG_texture_compression_pvrtc2; default: E2D_ASSERT_MSG(false, "unexpected pixel type"); return false; diff --git a/sources/enduro2d/core/render_impl/render_opengl_base.cpp b/sources/enduro2d/core/render_impl/render_opengl_base.cpp index ecf94386..e6b041a1 100644 --- a/sources/enduro2d/core/render_impl/render_opengl_base.cpp +++ b/sources/enduro2d/core/render_impl/render_opengl_base.cpp @@ -769,6 +769,9 @@ namespace e2d { namespace opengl DEFINE_CASE(rgba_pvrtc2, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG); DEFINE_CASE(rgba_pvrtc4, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG); + + DEFINE_CASE(rgba_pvrtc2_v2, GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG); + DEFINE_CASE(rgba_pvrtc4_v2, GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG); default: E2D_ASSERT_MSG(false, "unexpected pixel type"); return GL_RGBA; @@ -798,6 +801,9 @@ namespace e2d { namespace opengl DEFINE_CASE(rgba_pvrtc2, rgba_pvrtc2); DEFINE_CASE(rgba_pvrtc4, rgba_pvrtc4); + + DEFINE_CASE(rgba_pvrtc2_v2, rgba_pvrtc2_v2); + DEFINE_CASE(rgba_pvrtc4_v2, rgba_pvrtc4_v2); default: E2D_ASSERT_MSG(false, "unexpected image data format"); return pixel_declaration(pixel_declaration::pixel_type::rgba8);