add pvrtc v2

This commit is contained in:
2018-11-01 18:19:44 +07:00
parent ebfb9152cc
commit 431250d5bd
5 changed files with 56 additions and 21 deletions

View File

@@ -63,7 +63,10 @@ namespace e2d
rgb_pvrtc4, rgb_pvrtc4,
rgba_pvrtc2, rgba_pvrtc2,
rgba_pvrtc4 rgba_pvrtc4,
rgba_pvrtc2_v2,
rgba_pvrtc4_v2
}; };
static const char* pixel_type_to_cstr(pixel_type pt) noexcept; static const char* pixel_type_to_cstr(pixel_type pt) noexcept;
public: public:

View File

@@ -12,35 +12,38 @@ namespace
struct pixel_type_description { struct pixel_type_description {
const char* cstr; const char* cstr;
u32 minimal_size;
u32 bits_per_pixel; u32 bits_per_pixel;
bool color; bool color;
bool depth; bool depth;
bool stencil; bool stencil;
pixel_declaration::pixel_type type; pixel_declaration::pixel_type type;
bool compressed; bool compressed;
bool must_be_square;
bool must_be_power_of_two;
}; };
const pixel_type_description pixel_type_descriptions[] = { const pixel_type_description pixel_type_descriptions[] = {
{"depth16", 1, 16, false, true, false, pixel_declaration::pixel_type::depth16, false, false, false}, {"depth16", 16, false, true, false, pixel_declaration::pixel_type::depth16, false},
{"depth24", 1, 24, false, true, false, pixel_declaration::pixel_type::depth24, false, false, false}, {"depth24", 24, false, true, false, pixel_declaration::pixel_type::depth24, false},
{"depth32", 1, 32, false, true, false, pixel_declaration::pixel_type::depth32, false, false, false}, {"depth32", 32, false, true, false, pixel_declaration::pixel_type::depth32, false},
{"depth24_stencil8", 1, 32, false, true, true, pixel_declaration::pixel_type::depth24_stencil8, false, false, 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}, {"rgb8", 24, true, false, false, pixel_declaration::pixel_type::rgb8, false},
{"rgba8", 1, 32, true, false, false, pixel_declaration::pixel_type::rgba8, false, false, 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}, {"rgb_dxt1", 4, true, false, false, pixel_declaration::pixel_type::rgb_dxt1, true},
{"rgba_dxt1", 4, 4, true, false, false, pixel_declaration::pixel_type::rgba_dxt1, true, false, true}, {"rgba_dxt1", 4, true, false, false, pixel_declaration::pixel_type::rgba_dxt1, true},
{"rgba_dxt3", 4, 8, true, false, false, pixel_declaration::pixel_type::rgba_dxt3, true, false, true}, {"rgba_dxt3", 8, true, false, false, pixel_declaration::pixel_type::rgba_dxt3, true},
{"rgba_dxt5", 4, 8, true, false, false, pixel_declaration::pixel_type::rgba_dxt5, true, false, 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_pvrtc2", 2, true, false, false, pixel_declaration::pixel_type::rgb_pvrtc2, true},
{"rgb_pvrtc4", 8, 4, true, false, false, pixel_declaration::pixel_type::rgb_pvrtc4, true, true, true}, {"rgb_pvrtc4", 4, true, false, false, pixel_declaration::pixel_type::rgb_pvrtc4, true},
{"rgba_pvrtc2", 8, 2, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc2, true, true, true}, {"rgba_pvrtc2", 2, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc2, true},
{"rgba_pvrtc4", 8, 4, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc4, true, true, 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 { const pixel_type_description& get_pixel_type_description(pixel_declaration::pixel_type type) noexcept {

View File

@@ -238,14 +238,34 @@ namespace e2d
return *this; return *this;
} }
render& render::execute(const target_command& command) {
E2D_UNUSED(command);
return *this;
}
render& render::execute(const viewport_command& command) { render& render::execute(const viewport_command& command) {
E2D_UNUSED(command); E2D_UNUSED(command);
return *this; return *this;
} }
render& render::execute(const render_target_command& command) { const render::device_caps& render::device_capabilities() const noexcept {
E2D_UNUSED(command); static device_caps caps;
return *this; 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;
} }
} }

View File

@@ -1006,6 +1006,9 @@ namespace e2d
case pixel_declaration::pixel_type::rgba_pvrtc2: case pixel_declaration::pixel_type::rgba_pvrtc2:
case pixel_declaration::pixel_type::rgba_pvrtc4: case pixel_declaration::pixel_type::rgba_pvrtc4:
return __GLEW_IMG_texture_compression_pvrtc; 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: default:
E2D_ASSERT_MSG(false, "unexpected pixel type"); E2D_ASSERT_MSG(false, "unexpected pixel type");
return false; return false;

View File

@@ -769,6 +769,9 @@ namespace e2d { namespace opengl
DEFINE_CASE(rgba_pvrtc2, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG); DEFINE_CASE(rgba_pvrtc2, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG);
DEFINE_CASE(rgba_pvrtc4, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_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: default:
E2D_ASSERT_MSG(false, "unexpected pixel type"); E2D_ASSERT_MSG(false, "unexpected pixel type");
return GL_RGBA; return GL_RGBA;
@@ -798,6 +801,9 @@ namespace e2d { namespace opengl
DEFINE_CASE(rgba_pvrtc2, rgba_pvrtc2); DEFINE_CASE(rgba_pvrtc2, rgba_pvrtc2);
DEFINE_CASE(rgba_pvrtc4, rgba_pvrtc4); DEFINE_CASE(rgba_pvrtc4, rgba_pvrtc4);
DEFINE_CASE(rgba_pvrtc2_v2, rgba_pvrtc2_v2);
DEFINE_CASE(rgba_pvrtc4_v2, rgba_pvrtc4_v2);
default: default:
E2D_ASSERT_MSG(false, "unexpected image data format"); E2D_ASSERT_MSG(false, "unexpected image data format");
return pixel_declaration(pixel_declaration::pixel_type::rgba8); return pixel_declaration(pixel_declaration::pixel_type::rgba8);