add astc texture support

This commit is contained in:
2019-08-09 07:14:33 +07:00
parent ef9b214d2c
commit 2ca47055fb
16 changed files with 206 additions and 68 deletions

View File

@@ -63,6 +63,13 @@ namespace e2d
rgba_etc2, rgba_etc2,
rgb_a1_etc2, rgb_a1_etc2,
rgba_astc4x4,
rgba_astc5x5,
rgba_astc6x6,
rgba_astc8x8,
rgba_astc10x10,
rgba_astc12x12,
rgb_pvrtc2, rgb_pvrtc2,
rgb_pvrtc4, rgb_pvrtc4,
rgba_pvrtc2, rgba_pvrtc2,
@@ -86,8 +93,9 @@ namespace e2d
bool is_depth() const noexcept; bool is_depth() const noexcept;
bool is_stencil() const noexcept; bool is_stencil() const noexcept;
bool is_compressed() const noexcept; bool is_compressed() const noexcept;
std::size_t bits_per_pixel() const noexcept; v2u block_size() const noexcept;
v2u compressed_block_size() const noexcept; std::size_t bytes_per_block() const noexcept;
std::size_t data_size_for_dimension(v2u dim) const noexcept;
private: private:
pixel_type type_ = pixel_type::rgba8; pixel_type type_ = pixel_type::rgba8;
}; };
@@ -908,6 +916,7 @@ namespace e2d
bool dxt_compression_supported = false; bool dxt_compression_supported = false;
bool etc1_compression_supported = false; bool etc1_compression_supported = false;
bool etc2_compression_supported = false; bool etc2_compression_supported = false;
bool astc_compression_supported = false;
bool pvrtc_compression_supported = false; bool pvrtc_compression_supported = false;
bool pvrtc2_compression_supported = false; bool pvrtc2_compression_supported = false;
}; };

View File

@@ -39,6 +39,13 @@ namespace e2d
rgba_etc2, rgba_etc2,
rgb_a1_etc2, rgb_a1_etc2,
rgba_astc4x4,
rgba_astc5x5,
rgba_astc6x6,
rgba_astc8x8,
rgba_astc10x10,
rgba_astc12x12,
rgb_pvrtc2, rgb_pvrtc2,
rgb_pvrtc4, rgb_pvrtc4,
rgba_pvrtc2, rgba_pvrtc2,

View File

@@ -12,7 +12,7 @@ namespace
struct pixel_type_description { struct pixel_type_description {
const char* cstr; const char* cstr;
u32 bits_per_pixel; u32 bytes_per_block;
bool color; bool color;
bool depth; bool depth;
bool stencil; bool stencil;
@@ -22,36 +22,39 @@ namespace
}; };
const pixel_type_description pixel_type_descriptions[] = { const pixel_type_description pixel_type_descriptions[] = {
{"depth16", 16, false, true, false, pixel_declaration::pixel_type::depth16, false, v2u(1)}, {"depth16", 2, false, true, false, pixel_declaration::pixel_type::depth16, false, v2u(1,1)},
{"depth24", 24, false, true, false, pixel_declaration::pixel_type::depth24, false, v2u(1)}, {"depth24", 3, false, true, false, pixel_declaration::pixel_type::depth24, false, v2u(1,1)},
{"depth24_stencil8", 32, false, true, true, pixel_declaration::pixel_type::depth24_stencil8, false, v2u(1)}, {"depth24_stencil8", 4, false, true, true, pixel_declaration::pixel_type::depth24_stencil8, false, v2u(1,1)},
{"a8", 8, true, false, false, pixel_declaration::pixel_type::a8, false, v2u(1)}, {"a8", 1, true, false, false, pixel_declaration::pixel_type::a8, false, v2u(1,1)},
{"l8", 8, true, false, false, pixel_declaration::pixel_type::l8, false, v2u(1)}, {"l8", 1, true, false, false, pixel_declaration::pixel_type::l8, false, v2u(1,1)},
{"la8", 16, true, false, false, pixel_declaration::pixel_type::la8, false, v2u(1)}, {"la8", 2, true, false, false, pixel_declaration::pixel_type::la8, false, v2u(1,1)},
{"rgb8", 3, true, false, false, pixel_declaration::pixel_type::rgb8, false, v2u(1,1)},
{"rgba8", 4, true, false, false, pixel_declaration::pixel_type::rgba8, false, v2u(1,1)},
{"rgb8", 24, true, false, false, pixel_declaration::pixel_type::rgb8, false, v2u(1)}, {"rgba_dxt1", 8, true, false, false, pixel_declaration::pixel_type::rgba_dxt1, true, v2u(4,4)},
{"rgba8", 32, true, false, false, pixel_declaration::pixel_type::rgba8, false, v2u(1)}, {"rgba_dxt3", 16, true, false, false, pixel_declaration::pixel_type::rgba_dxt3, true, v2u(4,4)},
{"rgba_dxt5", 16, true, false, false, pixel_declaration::pixel_type::rgba_dxt5, true, v2u(4,4)},
{"rgba_dxt1", 4, true, false, false, pixel_declaration::pixel_type::rgba_dxt1, true, v2u(4,4)}, {"rgb_etc1", 8, true, false, false, pixel_declaration::pixel_type::rgb_etc1, true, v2u(4,4)},
{"rgba_dxt3", 8, true, false, false, pixel_declaration::pixel_type::rgba_dxt3, true, v2u(4,4)}, {"rgb_etc2", 8, true, false, false, pixel_declaration::pixel_type::rgb_etc2, true, v2u(4,4)},
{"rgba_dxt5", 8, true, false, false, pixel_declaration::pixel_type::rgba_dxt5, true, v2u(4,4)}, {"rgba_etc2", 16, true, false, false, pixel_declaration::pixel_type::rgba_etc2, true, v2u(4,4)},
{"rgb_a1_etc2", 8, true, false, false, pixel_declaration::pixel_type::rgb_a1_etc2, true, v2u(4,4)},
{"rgb_etc1", 4, true, false, false, pixel_declaration::pixel_type::rgb_etc1, true, v2u(4,4)}, {"rgba_astc4x4", 16, true, false, false, pixel_declaration::pixel_type::rgba_astc4x4, true, v2u(4,4)},
{"rgb_etc2", 4, true, false, false, pixel_declaration::pixel_type::rgb_etc2, true, v2u(4,4)}, {"rgba_astc5x5", 16, true, false, false, pixel_declaration::pixel_type::rgba_astc5x5, true, v2u(5,5)},
{"rgba_etc2", 8, true, false, false, pixel_declaration::pixel_type::rgba_etc2, true, v2u(4,4)}, {"rgba_astc6x6", 16, true, false, false, pixel_declaration::pixel_type::rgba_astc6x6, true, v2u(6,6)},
{"rgb_a1_etc2", 4, true, false, false, pixel_declaration::pixel_type::rgb_a1_etc2, true, v2u(4,4)}, {"rgba_astc8x8", 16, true, false, false, pixel_declaration::pixel_type::rgba_astc8x8, true, v2u(8,8)},
{"rgba_astc10x10", 16, true, false, false, pixel_declaration::pixel_type::rgba_astc10x10, true, v2u(10,10)},
{"rgba_astc12x12", 16, true, false, false, pixel_declaration::pixel_type::rgba_astc12x12, true, v2u(12,12)},
{"rgb_pvrtc2", 2, true, false, false, pixel_declaration::pixel_type::rgb_pvrtc2, true, v2u(8,4)}, {"rgb_pvrtc2", 8, true, false, false, pixel_declaration::pixel_type::rgb_pvrtc2, true, v2u(8,4)},
{"rgb_pvrtc4", 4, true, false, false, pixel_declaration::pixel_type::rgb_pvrtc4, true, v2u(4,4)}, {"rgb_pvrtc4", 8, true, false, false, pixel_declaration::pixel_type::rgb_pvrtc4, true, v2u(4,4)},
{"rgba_pvrtc2", 2, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc2, true, v2u(8,4)}, {"rgba_pvrtc2", 8, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc2, true, v2u(8,4)},
{"rgba_pvrtc4", 4, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc4, true, v2u(4,4)}, {"rgba_pvrtc4", 8, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc4, true, v2u(4,4)},
{"rgba_pvrtc2", 2, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc2, true, v2u(8,4)}, {"rgba_pvrtc2_v2", 8, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc2_v2, true, v2u(8,4)},
{"rgba_pvrtc4", 4, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc4, true, v2u(4,4)}, {"rgba_pvrtc4_v2", 8, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc4_v2, true, v2u(4,4)}
{"rgba_pvrtc2_v2", 2, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc2_v2, true, v2u(8,4)},
{"rgba_pvrtc4_v2", 4, true, false, false, pixel_declaration::pixel_type::rgba_pvrtc4_v2, true, v2u(4,4)}
}; };
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 {
@@ -165,12 +168,20 @@ namespace e2d
return get_pixel_type_description(type_).compressed; return get_pixel_type_description(type_).compressed;
} }
std::size_t pixel_declaration::bits_per_pixel() const noexcept { v2u pixel_declaration::block_size() const noexcept {
return get_pixel_type_description(type_).bits_per_pixel; return get_pixel_type_description(type_).block_size;
} }
v2u pixel_declaration::compressed_block_size() const noexcept { std::size_t pixel_declaration::bytes_per_block() const noexcept {
return get_pixel_type_description(type_).block_size; return get_pixel_type_description(type_).bytes_per_block;
}
std::size_t pixel_declaration::data_size_for_dimension(v2u dim) const noexcept {
const v2u bs = block_size();
const std::size_t bpb = bytes_per_block();
return bs.x > 0 && bs.y > 0 && bpb > 0
? bpb * ((dim.x + bs.x - 1u) / bs.x) * ((dim.y + bs.y - 1u) / bs.y)
: 0u;
} }
bool operator==(const pixel_declaration& l, const pixel_declaration& r) noexcept { bool operator==(const pixel_declaration& l, const pixel_declaration& r) noexcept {

View File

@@ -669,7 +669,7 @@ namespace e2d
with_gl_bind_texture(state_->dbg(), id, [this, &id, &size, &decl]() noexcept { with_gl_bind_texture(state_->dbg(), id, [this, &id, &size, &decl]() noexcept {
if ( decl.is_compressed() ) { if ( decl.is_compressed() ) {
buffer empty_data(decl.bits_per_pixel() * size.x * size.y / 8); buffer empty_data(decl.data_size_for_dimension(size));
GL_CHECK_CODE(state_->dbg(), glCompressedTexImage2D( GL_CHECK_CODE(state_->dbg(), glCompressedTexImage2D(
id.target(), id.target(),
0, 0,
@@ -1096,10 +1096,10 @@ namespace e2d
E2D_ASSERT(region.position.x < tex->size().x && region.position.y < tex->size().y); E2D_ASSERT(region.position.x < tex->size().x && region.position.y < tex->size().y);
E2D_ASSERT(region.position.x + region.size.x <= tex->size().x); E2D_ASSERT(region.position.x + region.size.x <= tex->size().x);
E2D_ASSERT(region.position.y + region.size.y <= tex->size().y); E2D_ASSERT(region.position.y + region.size.y <= tex->size().y);
E2D_ASSERT(pixels.size() == region.size.y * ((region.size.x * tex->decl().bits_per_pixel()) / 8u)); E2D_ASSERT(pixels.size() == tex->decl().data_size_for_dimension(region.size));
if ( tex->decl().is_compressed() ) { if ( tex->decl().is_compressed() ) {
const v2u block_size = tex->decl().compressed_block_size(); const v2u block_size = tex->decl().block_size();
E2D_ASSERT(region.position.x % block_size.x == 0 && region.position.y % block_size.y == 0); E2D_ASSERT(region.position.x % block_size.x == 0 && region.position.y % block_size.y == 0);
E2D_ASSERT(region.size.x % block_size.x == 0 && region.size.y % block_size.y == 0); E2D_ASSERT(region.size.x % block_size.x == 0 && region.size.y % block_size.y == 0);
opengl::with_gl_bind_texture(state_->dbg(), tex->state().id(), opengl::with_gl_bind_texture(state_->dbg(), tex->state().id(),
@@ -1146,36 +1146,53 @@ namespace e2d
case pixel_declaration::pixel_type::depth16: case pixel_declaration::pixel_type::depth16:
return caps.depth_texture_supported return caps.depth_texture_supported
&& caps.depth16_supported; && caps.depth16_supported;
case pixel_declaration::pixel_type::depth24: case pixel_declaration::pixel_type::depth24:
return caps.depth_texture_supported return caps.depth_texture_supported
&& caps.depth24_supported; && caps.depth24_supported;
case pixel_declaration::pixel_type::depth24_stencil8: case pixel_declaration::pixel_type::depth24_stencil8:
return caps.depth_texture_supported return caps.depth_texture_supported
&& caps.depth24_stencil8_supported; && caps.depth24_stencil8_supported;
case pixel_declaration::pixel_type::a8: case pixel_declaration::pixel_type::a8:
case pixel_declaration::pixel_type::l8: case pixel_declaration::pixel_type::l8:
case pixel_declaration::pixel_type::la8: case pixel_declaration::pixel_type::la8:
case pixel_declaration::pixel_type::rgb8: case pixel_declaration::pixel_type::rgb8:
case pixel_declaration::pixel_type::rgba8: case pixel_declaration::pixel_type::rgba8:
return true; return true;
case pixel_declaration::pixel_type::rgba_dxt1: case pixel_declaration::pixel_type::rgba_dxt1:
case pixel_declaration::pixel_type::rgba_dxt3: case pixel_declaration::pixel_type::rgba_dxt3:
case pixel_declaration::pixel_type::rgba_dxt5: case pixel_declaration::pixel_type::rgba_dxt5:
return caps.dxt_compression_supported; return caps.dxt_compression_supported;
case pixel_declaration::pixel_type::rgb_etc1: case pixel_declaration::pixel_type::rgb_etc1:
return caps.etc1_compression_supported; return caps.etc1_compression_supported;
case pixel_declaration::pixel_type::rgb_etc2: case pixel_declaration::pixel_type::rgb_etc2:
case pixel_declaration::pixel_type::rgba_etc2: case pixel_declaration::pixel_type::rgba_etc2:
case pixel_declaration::pixel_type::rgb_a1_etc2: case pixel_declaration::pixel_type::rgb_a1_etc2:
return caps.etc2_compression_supported; return caps.etc2_compression_supported;
case pixel_declaration::pixel_type::rgba_astc4x4:
case pixel_declaration::pixel_type::rgba_astc5x5:
case pixel_declaration::pixel_type::rgba_astc6x6:
case pixel_declaration::pixel_type::rgba_astc8x8:
case pixel_declaration::pixel_type::rgba_astc10x10:
case pixel_declaration::pixel_type::rgba_astc12x12:
return caps.astc_compression_supported;
case pixel_declaration::pixel_type::rgb_pvrtc2: case pixel_declaration::pixel_type::rgb_pvrtc2:
case pixel_declaration::pixel_type::rgb_pvrtc4: case pixel_declaration::pixel_type::rgb_pvrtc4:
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 caps.pvrtc_compression_supported; return caps.pvrtc_compression_supported;
case pixel_declaration::pixel_type::rgba_pvrtc2_v2: case pixel_declaration::pixel_type::rgba_pvrtc2_v2:
case pixel_declaration::pixel_type::rgba_pvrtc4_v2: case pixel_declaration::pixel_type::rgba_pvrtc4_v2:
return caps.pvrtc2_compression_supported; return caps.pvrtc2_compression_supported;
default: default:
E2D_ASSERT_MSG(false, "unexpected pixel type"); E2D_ASSERT_MSG(false, "unexpected pixel type");
return false; return false;

View File

@@ -843,6 +843,13 @@ namespace e2d::opengl
DEFINE_CASE(rgba_etc2, GL_COMPRESSED_RGBA8_ETC2_EAC); DEFINE_CASE(rgba_etc2, GL_COMPRESSED_RGBA8_ETC2_EAC);
DEFINE_CASE(rgb_a1_etc2, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2); DEFINE_CASE(rgb_a1_etc2, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2);
DEFINE_CASE(rgba_astc4x4, GL_COMPRESSED_RGBA_ASTC_4x4_KHR);
DEFINE_CASE(rgba_astc5x5, GL_COMPRESSED_RGBA_ASTC_5x5_KHR);
DEFINE_CASE(rgba_astc6x6, GL_COMPRESSED_RGBA_ASTC_6x6_KHR);
DEFINE_CASE(rgba_astc8x8, GL_COMPRESSED_RGBA_ASTC_8x8_KHR);
DEFINE_CASE(rgba_astc10x10, GL_COMPRESSED_RGBA_ASTC_10x10_KHR);
DEFINE_CASE(rgba_astc12x12, GL_COMPRESSED_RGBA_ASTC_12x12_KHR);
DEFINE_CASE(rgb_pvrtc2, GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG); DEFINE_CASE(rgb_pvrtc2, GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG);
DEFINE_CASE(rgb_pvrtc4, GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG); DEFINE_CASE(rgb_pvrtc4, GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG);
DEFINE_CASE(rgba_pvrtc2, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG); DEFINE_CASE(rgba_pvrtc2, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG);
@@ -879,6 +886,13 @@ namespace e2d::opengl
DEFINE_CASE(rgba_etc2, rgba_etc2); DEFINE_CASE(rgba_etc2, rgba_etc2);
DEFINE_CASE(rgb_a1_etc2, rgb_a1_etc2); DEFINE_CASE(rgb_a1_etc2, rgb_a1_etc2);
DEFINE_CASE(rgba_astc4x4, rgba_astc4x4);
DEFINE_CASE(rgba_astc5x5, rgba_astc5x5);
DEFINE_CASE(rgba_astc6x6, rgba_astc6x6);
DEFINE_CASE(rgba_astc8x8, rgba_astc8x8);
DEFINE_CASE(rgba_astc10x10, rgba_astc10x10);
DEFINE_CASE(rgba_astc12x12, rgba_astc12x12);
DEFINE_CASE(rgb_pvrtc2, rgb_pvrtc2); DEFINE_CASE(rgb_pvrtc2, rgb_pvrtc2);
DEFINE_CASE(rgb_pvrtc4, rgb_pvrtc4); DEFINE_CASE(rgb_pvrtc4, rgb_pvrtc4);
DEFINE_CASE(rgba_pvrtc2, rgba_pvrtc2); DEFINE_CASE(rgba_pvrtc2, rgba_pvrtc2);
@@ -1442,6 +1456,12 @@ namespace e2d::opengl
gl_has_any_extension(debug, gl_has_any_extension(debug,
"GL_ARB_ES3_compatibility"); "GL_ARB_ES3_compatibility");
caps.astc_compression_supported =
gl_has_any_extension(debug,
"GL_OES_texture_compression_astc",
"GL_KHR_texture_compression_astc_ldr",
"GL_KHR_texture_compression_astc_hdr");
caps.pvrtc_compression_supported = caps.pvrtc_compression_supported =
gl_has_any_extension(debug, gl_has_any_extension(debug,
"GL_IMG_texture_compression_pvrtc"); "GL_IMG_texture_compression_pvrtc");

View File

@@ -11,34 +11,41 @@ namespace
using namespace e2d; using namespace e2d;
struct data_format_description { struct data_format_description {
u32 bits_per_pixel; u32 uncompressed_bytes_per_pixel;
image_data_format format; image_data_format format;
bool compressed; bool compressed;
}; };
const data_format_description data_format_descriptions[] = { const data_format_description data_format_descriptions[] = {
{ 8, image_data_format::a8, false}, {1, image_data_format::a8, false},
{ 8, image_data_format::l8, false}, {1, image_data_format::l8, false},
{16, image_data_format::la8, false}, {2, image_data_format::la8, false},
{24, image_data_format::rgb8, false}, {3, image_data_format::rgb8, false},
{32, image_data_format::rgba8, false}, {4, image_data_format::rgba8, false},
{ 4, image_data_format::rgba_dxt1, true}, {0, image_data_format::rgba_dxt1, true},
{ 8, image_data_format::rgba_dxt3, true}, {0, image_data_format::rgba_dxt3, true},
{ 8, image_data_format::rgba_dxt5, true}, {0, image_data_format::rgba_dxt5, true},
{ 4, image_data_format::rgb_etc1, true}, {0, image_data_format::rgb_etc1, true},
{ 4, image_data_format::rgb_etc2, true}, {0, image_data_format::rgb_etc2, true},
{ 8, image_data_format::rgba_etc2, true}, {0, image_data_format::rgba_etc2, true},
{ 4, image_data_format::rgb_a1_etc2, true}, {0, image_data_format::rgb_a1_etc2, true},
{ 2, image_data_format::rgb_pvrtc2, true}, {0, image_data_format::rgba_astc4x4, true},
{ 4, image_data_format::rgb_pvrtc4, true}, {0, image_data_format::rgba_astc5x5, true},
{ 2, image_data_format::rgba_pvrtc2, true}, {0, image_data_format::rgba_astc6x6, true},
{ 4, image_data_format::rgba_pvrtc4, true}, {0, image_data_format::rgba_astc8x8, true},
{0, image_data_format::rgba_astc10x10, true},
{0, image_data_format::rgba_astc12x12, true},
{ 2, image_data_format::rgba_pvrtc2_v2, true}, {0, image_data_format::rgb_pvrtc2, true},
{ 4, image_data_format::rgba_pvrtc4_v2, true} {0, image_data_format::rgb_pvrtc4, true},
{0, image_data_format::rgba_pvrtc2, true},
{0, image_data_format::rgba_pvrtc4, true},
{0, image_data_format::rgba_pvrtc2_v2, true},
{0, image_data_format::rgba_pvrtc4_v2, true}
}; };
const data_format_description& get_data_format_description(image_data_format format) noexcept { const data_format_description& get_data_format_description(image_data_format format) noexcept {
@@ -132,10 +139,8 @@ namespace e2d
throw bad_image_access(); throw bad_image_access();
} }
const std::size_t bits_per_pixel = format_desc.bits_per_pixel; const std::size_t bytes_per_pixel = format_desc.uncompressed_bytes_per_pixel;
const std::size_t bytes_per_pixel = bits_per_pixel / 8;
const std::size_t stride_in_bytes = size_.x * bytes_per_pixel; const std::size_t stride_in_bytes = size_.x * bytes_per_pixel;
E2D_ASSERT(bits_per_pixel % 8 == 0);
const std::size_t pixel_index = v * stride_in_bytes + u * bytes_per_pixel; const std::size_t pixel_index = v * stride_in_bytes + u * bytes_per_pixel;
E2D_ASSERT(pixel_index + bytes_per_pixel <= data_.size()); E2D_ASSERT(pixel_index + bytes_per_pixel <= data_.size());

View File

@@ -128,6 +128,42 @@ namespace
image_data_format::rgb_a1_etc2, image_data_format::rgb_a1_etc2,
8, 8,
{4,4}}; {4,4}};
case pvr_pixel_format::astc_4x4:
return {
buffer(content),
image_data_format::rgba_astc4x4,
16,
{4,4}};
case pvr_pixel_format::astc_5x5:
return {
buffer(content),
image_data_format::rgba_astc5x5,
16,
{5,5}};
case pvr_pixel_format::astc_6x6:
return {
buffer(content),
image_data_format::rgba_astc6x6,
16,
{6,6}};
case pvr_pixel_format::astc_8x8:
return {
buffer(content),
image_data_format::rgba_astc8x8,
16,
{8,8}};
case pvr_pixel_format::astc_10x10:
return {
buffer(content),
image_data_format::rgba_astc10x10,
16,
{10,10}};
case pvr_pixel_format::astc_12x12:
return {
buffer(content),
image_data_format::rgba_astc12x12,
16,
{12,12}};
case pvr_pixel_format::a8: case pvr_pixel_format::a8:
return { return {
buffer(content), buffer(content),

View File

@@ -29,6 +29,13 @@ namespace
case image_data_format::rgba_etc2: return pvr_pixel_format::etc2_rgba; case image_data_format::rgba_etc2: return pvr_pixel_format::etc2_rgba;
case image_data_format::rgb_a1_etc2: return pvr_pixel_format::etc2_rgb_a1; case image_data_format::rgb_a1_etc2: return pvr_pixel_format::etc2_rgb_a1;
case image_data_format::rgba_astc4x4: return pvr_pixel_format::astc_4x4;
case image_data_format::rgba_astc5x5: return pvr_pixel_format::astc_5x5;
case image_data_format::rgba_astc6x6: return pvr_pixel_format::astc_6x6;
case image_data_format::rgba_astc8x8: return pvr_pixel_format::astc_8x8;
case image_data_format::rgba_astc10x10: return pvr_pixel_format::astc_10x10;
case image_data_format::rgba_astc12x12: return pvr_pixel_format::astc_12x12;
case image_data_format::rgb_pvrtc2: return pvr_pixel_format::pvrtc_2bpp_rgb; case image_data_format::rgb_pvrtc2: return pvr_pixel_format::pvrtc_2bpp_rgb;
case image_data_format::rgb_pvrtc4: return pvr_pixel_format::pvrtc_4bpp_rgb; case image_data_format::rgb_pvrtc4: return pvr_pixel_format::pvrtc_4bpp_rgb;
case image_data_format::rgba_pvrtc2: return pvr_pixel_format::pvrtc_2bpp_rgba; case image_data_format::rgba_pvrtc2: return pvr_pixel_format::pvrtc_2bpp_rgba;
@@ -62,6 +69,13 @@ namespace e2d::images::impl
case image_data_format::rgba_etc2: case image_data_format::rgba_etc2:
case image_data_format::rgb_a1_etc2: case image_data_format::rgb_a1_etc2:
case image_data_format::rgba_astc4x4:
case image_data_format::rgba_astc5x5:
case image_data_format::rgba_astc6x6:
case image_data_format::rgba_astc8x8:
case image_data_format::rgba_astc10x10:
case image_data_format::rgba_astc12x12:
case image_data_format::rgb_pvrtc2: case image_data_format::rgb_pvrtc2:
case image_data_format::rgb_pvrtc4: case image_data_format::rgb_pvrtc4:
case image_data_format::rgba_pvrtc2: case image_data_format::rgba_pvrtc2:

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d1160fde2e2877bb2db8698af35f5e5e58daf4d10711eda1a2ccaa56472aeefe
size 1523

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:33ca8d0e768cf02071c59c468da5524d33d03888cd0e13db2a9e380d1ae1de73
size 1123

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0ab8a200daa2640c60454085835ed19622e0e344fd07c9bcb9f8b51584e4009a
size 8259

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:682e37f45057fb498dafcbea955bfdb293ad6041f21b0ff03d26038008a4d2e0
size 5475

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c5210127b811bc455dfa13a0b7f572652ec3ae711ce39a18ac1c138c4f230eac
size 3939

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:558f5ca61535e42a3f7823f572f80342f91d30d223e19b081121a69cf6274178
size 2115

View File

@@ -190,8 +190,7 @@ TEST_CASE("render"){
texture_ptr tex = r.create_texture(v2u(128,128), pixel_declaration::pixel_type::rgba8); texture_ptr tex = r.create_texture(v2u(128,128), pixel_declaration::pixel_type::rgba8);
REQUIRE(tex != nullptr); REQUIRE(tex != nullptr);
buffer src; buffer src(tex->size().x * tex->size().y * 4u);
src.resize(((tex->size().x * tex->decl().bits_per_pixel()) / 8u) * tex->size().y);
for ( auto& c : src ) { for ( auto& c : src ) {
c = rand() % 255; c = rand() % 255;
} }
@@ -201,8 +200,7 @@ TEST_CASE("render"){
texture_ptr tex = r.create_texture(v2u(128,128), pixel_declaration::pixel_type::l8); texture_ptr tex = r.create_texture(v2u(128,128), pixel_declaration::pixel_type::l8);
REQUIRE(tex != nullptr); REQUIRE(tex != nullptr);
buffer src; buffer src(tex->size().x * tex->size().y * 1u);
src.resize(((tex->size().x * tex->decl().bits_per_pixel()) / 8u) * tex->size().y);
for ( auto& c : src ) { for ( auto& c : src ) {
c = rand() % 255; c = rand() % 255;
} }
@@ -212,8 +210,7 @@ TEST_CASE("render"){
texture_ptr tex = r.create_texture(v2u(128,128), pixel_declaration::pixel_type::rgb8); texture_ptr tex = r.create_texture(v2u(128,128), pixel_declaration::pixel_type::rgb8);
REQUIRE(tex != nullptr); REQUIRE(tex != nullptr);
buffer src; buffer src(tex->size().x * tex->size().y * 3u);
src.resize(((tex->size().x * tex->decl().bits_per_pixel()) / 8u) * tex->size().y);
for ( auto& c : src ) { for ( auto& c : src ) {
c = rand() % 255; c = rand() % 255;
} }
@@ -223,8 +220,7 @@ TEST_CASE("render"){
texture_ptr tex = r.create_texture(v2u(57,31), pixel_declaration::pixel_type::rgba8); texture_ptr tex = r.create_texture(v2u(57,31), pixel_declaration::pixel_type::rgba8);
REQUIRE(tex != nullptr); REQUIRE(tex != nullptr);
buffer src; buffer src(tex->size().x * tex->size().y * 4u);
src.resize(((tex->size().x * tex->decl().bits_per_pixel()) / 8u) * tex->size().y);
for ( auto& c : src ) { for ( auto& c : src ) {
c = rand() % 255; c = rand() % 255;
} }
@@ -234,8 +230,7 @@ TEST_CASE("render"){
texture_ptr tex = r.create_texture(v2u(128,128), pixel_declaration::pixel_type::rgba8); texture_ptr tex = r.create_texture(v2u(128,128), pixel_declaration::pixel_type::rgba8);
REQUIRE(tex != nullptr); REQUIRE(tex != nullptr);
buffer src; buffer src(31u * 44u * 4u);
src.resize(((31 * tex->decl().bits_per_pixel()) / 8u) * 44);
for ( auto& c : src ) { for ( auto& c : src ) {
c = rand() % 255; c = rand() % 255;
} }
@@ -245,8 +240,7 @@ TEST_CASE("render"){
texture_ptr tex = r.create_texture(v2u(128,128), pixel_declaration::pixel_type::rgba8); texture_ptr tex = r.create_texture(v2u(128,128), pixel_declaration::pixel_type::rgba8);
REQUIRE(tex != nullptr); REQUIRE(tex != nullptr);
buffer src; buffer src(31u * 44u * 4u);
src.resize(((31 * tex->decl().bits_per_pixel()) / 8u) * 44);
for ( auto& c : src ) { for ( auto& c : src ) {
c = rand() % 255; c = rand() % 255;
} }

View File

@@ -291,6 +291,13 @@ TEST_CASE("images") {
{"bin/images/pvr/ship_etc2_rgba.pvr", 64 * 128 * 8 / 8, true, image_data_format::rgba_etc2}, {"bin/images/pvr/ship_etc2_rgba.pvr", 64 * 128 * 8 / 8, true, image_data_format::rgba_etc2},
{"bin/images/pvr/ship_etc2_rgb_a1.pvr", 64 * 128 * 4 / 8, true, image_data_format::rgb_a1_etc2}, {"bin/images/pvr/ship_etc2_rgb_a1.pvr", 64 * 128 * 4 / 8, true, image_data_format::rgb_a1_etc2},
{"bin/images/pvr/ship_astc4x4.pvr", ((64+3)/4) * ((128+3)/4) * 16, true, image_data_format::rgba_astc4x4},
{"bin/images/pvr/ship_astc5x5.pvr", ((64+4)/5) * ((128+4)/5) * 16, true, image_data_format::rgba_astc5x5},
{"bin/images/pvr/ship_astc6x6.pvr", ((64+5)/6) * ((128+5)/6) * 16, true, image_data_format::rgba_astc6x6},
{"bin/images/pvr/ship_astc8x8.pvr", ((64+7)/8) * ((128+7)/8) * 16, true, image_data_format::rgba_astc8x8},
{"bin/images/pvr/ship_astc10x10.pvr", ((64+9)/10) * ((128+9)/10) * 16, true, image_data_format::rgba_astc10x10},
{"bin/images/pvr/ship_astc12x12.pvr", ((64+11)/12) * ((128+11)/12) * 16, true, image_data_format::rgba_astc12x12},
{"bin/images/pvr/ship_pvrtc_2bpp_rgb.pvr", 64 * 128 * 2 / 8, true, image_data_format::rgb_pvrtc2}, {"bin/images/pvr/ship_pvrtc_2bpp_rgb.pvr", 64 * 128 * 2 / 8, true, image_data_format::rgb_pvrtc2},
{"bin/images/pvr/ship_pvrtc_2bpp_rgba.pvr", 64 * 128 * 2 / 8, true, image_data_format::rgba_pvrtc2}, {"bin/images/pvr/ship_pvrtc_2bpp_rgba.pvr", 64 * 128 * 2 / 8, true, image_data_format::rgba_pvrtc2},
{"bin/images/pvr/ship_pvrtc_4bpp_rgb.pvr", 64 * 128 * 4 / 8, true, image_data_format::rgb_pvrtc4}, {"bin/images/pvr/ship_pvrtc_4bpp_rgb.pvr", 64 * 128 * 4 / 8, true, image_data_format::rgb_pvrtc4},