diff --git a/examples/08-update/update.cpp b/examples/08-update/update.cpp index 8e0b1ffba..ab0db8099 100644 --- a/examples/08-update/update.cpp +++ b/examples/08-update/update.cpp @@ -171,15 +171,19 @@ public: // Create vertex stream declaration. PosTexcoordVertex::init(); - m_textures[0] = loadTexture("textures/texture_compression_bc1.ktx", BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP); - m_textures[1] = loadTexture("textures/texture_compression_bc2.ktx", BGFX_TEXTURE_U_CLAMP); - m_textures[2] = loadTexture("textures/texture_compression_bc3.ktx", BGFX_TEXTURE_V_CLAMP); - m_textures[3] = loadTexture("textures/texture_compression_etc1.ktx", BGFX_TEXTURE_U_BORDER|BGFX_TEXTURE_V_BORDER|BGFX_TEXTURE_BORDER_COLOR(1) ); - m_textures[4] = loadTexture("textures/texture_compression_etc2.ktx"); - m_textures[5] = loadTexture("textures/texture_compression_ptc12.pvr"); - m_textures[6] = loadTexture("textures/texture_compression_ptc14.pvr"); - m_textures[7] = loadTexture("textures/texture_compression_ptc22.pvr"); - m_textures[8] = loadTexture("textures/texture_compression_ptc24.pvr"); + m_textures[ 0] = loadTexture("textures/texture_compression_bc1.ktx", BGFX_TEXTURE_U_CLAMP | BGFX_TEXTURE_V_CLAMP); + m_textures[ 1] = loadTexture("textures/texture_compression_bc2.ktx", BGFX_TEXTURE_U_CLAMP); + m_textures[ 2] = loadTexture("textures/texture_compression_bc3.ktx", BGFX_TEXTURE_V_CLAMP); + m_textures[ 3] = loadTexture("textures/texture_compression_etc1.ktx", BGFX_TEXTURE_U_BORDER | BGFX_TEXTURE_V_BORDER | BGFX_TEXTURE_BORDER_COLOR(1)); + m_textures[ 4] = loadTexture("textures/texture_compression_etc2.ktx"); + m_textures[ 5] = loadTexture("textures/texture_compression_ptc12.pvr"); + m_textures[ 6] = loadTexture("textures/texture_compression_ptc14.pvr"); + m_textures[ 7] = loadTexture("textures/texture_compression_ptc22.pvr"); + m_textures[ 8] = loadTexture("textures/texture_compression_ptc24.pvr"); + m_textures[ 9] = loadTexture("textures/texture_compression_atc.dds"); + m_textures[10] = loadTexture("textures/texture_compression_atci.dds"); + m_textures[11] = loadTexture("textures/texture_compression_atce.dds"); + BX_STATIC_ASSERT(12 == BX_COUNTOF(m_textures)); const bgfx::Caps* caps = bgfx::getCaps(); m_texture3DSupported = !!(caps->supported & BGFX_CAPS_TEXTURE_3D); @@ -519,13 +523,16 @@ public: // Set view and projection matrix for view 1. const float aspectRatio = float(m_height)/float(m_width); - const float size = 11.0f; + const float margin = 0.7f; + const float sizeX = 0.5f * BX_COUNTOF(m_textures) * 2.1f + margin; + const float sizeY = sizeX * aspectRatio; + const bgfx::Caps* caps = bgfx::getCaps(); - bx::mtxOrtho(proj, -size, size, size*aspectRatio, -size*aspectRatio, 0.0f, 1000.0f, 0.0f, caps->homogeneousDepth); + bx::mtxOrtho(proj, -sizeX, sizeX, sizeY, -sizeY, 0.0f, 1000.0f, 0.0f, caps->homogeneousDepth); bgfx::setViewTransform(1, NULL, proj); float mtx[16]; - bx::mtxTranslate(mtx, -size+2.0f - BX_COUNTOF(m_textures)*0.1f*0.5f, 1.9f, 0.0f); + bx::mtxTranslate(mtx, -sizeX + margin + 1.0f, 1.9f, 0.0f); // Set model matrix for rendering. bgfx::setTransform(mtx); @@ -543,11 +550,11 @@ public: // Submit primitive for rendering to view 1. bgfx::submit(1, m_programCmp); - const float xpos = -size+2.0f - BX_COUNTOF(m_textures)*0.1f*0.5f; + const float xpos = -sizeX + margin + 1.0f; for (uint32_t ii = 0; ii < BX_COUNTOF(m_textures); ++ii) { - bx::mtxTranslate(mtx, xpos + ii*2.1f, size-6.5f, 0.0f); + bx::mtxTranslate(mtx, xpos + ii*2.1f, sizeY - margin - 1.0f, 0.0f); // Set model matrix for rendering. bgfx::setTransform(mtx); @@ -568,7 +575,7 @@ public: for (uint32_t ii = 0; ii < m_numTextures3d; ++ii) { - bx::mtxTranslate(mtx, xpos + (ii+3)*2.1f, -size+6.5f, 0.0f); + bx::mtxTranslate(mtx, xpos + (ii+(BX_COUNTOF(m_textures) - m_numTextures3d)*0.5f)*2.1f, -sizeY + margin + 1.0f, 0.0f); // Set model matrix for rendering. bgfx::setTransform(mtx); @@ -589,7 +596,7 @@ public: for (uint32_t ii = 0; ii < 4; ++ii) { - bx::mtxTranslate(mtx, xpos + (size-2.0f)*2.1f, -size+6.5f + ii*2.1f, 0.0f); + bx::mtxTranslate(mtx, sizeX - margin - 1.0f, -sizeY + margin + 1.0f + ii*2.1f, 0.0f); // Set model matrix for rendering. bgfx::setTransform(mtx); @@ -643,7 +650,7 @@ public: uint8_t m_gg; uint8_t m_bb; - bgfx::TextureHandle m_textures[9]; + bgfx::TextureHandle m_textures[12]; bgfx::TextureHandle m_textures3d[3]; bgfx::TextureHandle m_texture2d; bgfx::TextureHandle m_textureCube[3]; diff --git a/examples/runtime/textures/texture_compression_astc_10x5.dds b/examples/runtime/textures/texture_compression_astc_10x5.dds new file mode 100644 index 000000000..5d8393954 Binary files /dev/null and b/examples/runtime/textures/texture_compression_astc_10x5.dds differ diff --git a/examples/runtime/textures/texture_compression_astc_4x4.dds b/examples/runtime/textures/texture_compression_astc_4x4.dds new file mode 100644 index 000000000..ada6b45d9 Binary files /dev/null and b/examples/runtime/textures/texture_compression_astc_4x4.dds differ diff --git a/examples/runtime/textures/texture_compression_astc_5x5.dds b/examples/runtime/textures/texture_compression_astc_5x5.dds new file mode 100644 index 000000000..bfce30422 Binary files /dev/null and b/examples/runtime/textures/texture_compression_astc_5x5.dds differ diff --git a/examples/runtime/textures/texture_compression_astc_6x6.dds b/examples/runtime/textures/texture_compression_astc_6x6.dds new file mode 100644 index 000000000..a1215b7f9 Binary files /dev/null and b/examples/runtime/textures/texture_compression_astc_6x6.dds differ diff --git a/examples/runtime/textures/texture_compression_astc_8x5.dds b/examples/runtime/textures/texture_compression_astc_8x5.dds new file mode 100644 index 000000000..55d1754fb Binary files /dev/null and b/examples/runtime/textures/texture_compression_astc_8x5.dds differ diff --git a/examples/runtime/textures/texture_compression_astc_8x6.dds b/examples/runtime/textures/texture_compression_astc_8x6.dds new file mode 100644 index 000000000..e205b999c Binary files /dev/null and b/examples/runtime/textures/texture_compression_astc_8x6.dds differ diff --git a/examples/runtime/textures/texture_compression_atc.dds b/examples/runtime/textures/texture_compression_atc.dds new file mode 100644 index 000000000..be2aeb7d4 Binary files /dev/null and b/examples/runtime/textures/texture_compression_atc.dds differ diff --git a/examples/runtime/textures/texture_compression_atce.dds b/examples/runtime/textures/texture_compression_atce.dds new file mode 100644 index 000000000..5d1cabd07 Binary files /dev/null and b/examples/runtime/textures/texture_compression_atce.dds differ diff --git a/examples/runtime/textures/texture_compression_atci.dds b/examples/runtime/textures/texture_compression_atci.dds new file mode 100644 index 000000000..57eadf20c Binary files /dev/null and b/examples/runtime/textures/texture_compression_atci.dds differ diff --git a/include/bgfx/bgfx.h b/include/bgfx/bgfx.h index 3aa013119..93aee62cf 100644 --- a/include/bgfx/bgfx.h +++ b/include/bgfx/bgfx.h @@ -183,7 +183,7 @@ namespace bgfx ASTC8x6, //!< ASTC 8x6 2.67 BPP ASTC10x5, //!< ASTC 10x5 2.56 BPP - Unknown, // Compressed formats above. + Unknown, // Compressed formats above. R1, A8, diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 1e9a0f8cb..5e2e4a0f7 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -1404,6 +1404,9 @@ namespace bgfx TextureFormat::PTC14A, TextureFormat::PTC22, TextureFormat::PTC24, + TextureFormat::ATC, + TextureFormat::ATCE, + TextureFormat::ATCI, TextureFormat::BGRA8, // GL doesn't support BGRA8 without extensions. TextureFormat::RGBA8, // D3D9 doesn't support RGBA8 }; @@ -4467,6 +4470,15 @@ BGFX_TEXTURE_FORMAT_BIMG(PTC12A); BGFX_TEXTURE_FORMAT_BIMG(PTC14A); BGFX_TEXTURE_FORMAT_BIMG(PTC22); BGFX_TEXTURE_FORMAT_BIMG(PTC24); +BGFX_TEXTURE_FORMAT_BIMG(ATC); +BGFX_TEXTURE_FORMAT_BIMG(ATCE); +BGFX_TEXTURE_FORMAT_BIMG(ATCI); +BGFX_TEXTURE_FORMAT_BIMG(ASTC4x4); +BGFX_TEXTURE_FORMAT_BIMG(ASTC5x5); +BGFX_TEXTURE_FORMAT_BIMG(ASTC6x6); +BGFX_TEXTURE_FORMAT_BIMG(ASTC8x5); +BGFX_TEXTURE_FORMAT_BIMG(ASTC8x6); +BGFX_TEXTURE_FORMAT_BIMG(ASTC10x5); BGFX_TEXTURE_FORMAT_BIMG(Unknown); BGFX_TEXTURE_FORMAT_BIMG(R1); BGFX_TEXTURE_FORMAT_BIMG(A8); diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 373021e9a..999824265 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -218,7 +218,6 @@ namespace bgfx { namespace d3d11 { DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // ASTC8x6 { DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // ASTC10x5 { DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // Unknown - { DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // Unknown { DXGI_FORMAT_R1_UNORM, DXGI_FORMAT_R1_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // R1 { DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_A8_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // A8 { DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // R8 diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index 8c1fc7ba5..862ba5faa 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -195,7 +195,6 @@ namespace bgfx { namespace d3d12 { DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // PTC14A { DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // PTC22 { DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // PTC24 - { DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // PTC24 { DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // ATC { DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // ATCE { DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN }, // ATCI diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 609880bd5..07b6c8806 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -201,6 +201,15 @@ namespace bgfx { namespace gl { GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, GL_ZERO, false }, // PTC14A { GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG, GL_ZERO, GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG, GL_ZERO, false }, // PTC22 { GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG, GL_ZERO, GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG, GL_ZERO, false }, // PTC24 + { GL_ATC_RGB_AMD, GL_ZERO, GL_ATC_RGB_AMD, GL_ZERO, false }, // ATC + { GL_ATC_RGBA_EXPLICIT_ALPHA_AMD, GL_ZERO, GL_ATC_RGBA_EXPLICIT_ALPHA_AMD, GL_ZERO, false }, // ATCE + { GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD, GL_ZERO, GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD, GL_ZERO, false }, // ATCI + { GL_COMPRESSED_RGBA_ASTC_4x4_KHR, GL_COMPRESSED_SRGB8_ASTC_4x4_KHR, GL_COMPRESSED_RGBA_ASTC_4x4_KHR, GL_ZERO, false }, // ASTC4x4 + { GL_COMPRESSED_RGBA_ASTC_5x5_KHR, GL_COMPRESSED_SRGB8_ASTC_5x5_KHR, GL_COMPRESSED_RGBA_ASTC_5x5_KHR, GL_ZERO, false }, // ASTC5x5 + { GL_COMPRESSED_RGBA_ASTC_6x6_KHR, GL_COMPRESSED_SRGB8_ASTC_6x6_KHR, GL_COMPRESSED_RGBA_ASTC_6x6_KHR, GL_ZERO, false }, // ASTC6x6 + { GL_COMPRESSED_RGBA_ASTC_8x5_KHR, GL_COMPRESSED_SRGB8_ASTC_8x5_KHR, GL_COMPRESSED_RGBA_ASTC_8x5_KHR, GL_ZERO, false }, // ASTC8x5 + { GL_COMPRESSED_RGBA_ASTC_8x6_KHR, GL_COMPRESSED_SRGB8_ASTC_8x6_KHR, GL_COMPRESSED_RGBA_ASTC_8x6_KHR, GL_ZERO, false }, // ASTC8x6 + { GL_COMPRESSED_RGBA_ASTC_10x5_KHR, GL_COMPRESSED_SRGB8_ASTC_10x5_KHR, GL_COMPRESSED_RGBA_ASTC_10x5_KHR, GL_ZERO, false }, // ASTC10x5 { GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO, false }, // Unknown { GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO, false }, // ATC { GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO, false }, // ATCE diff --git a/src/renderer_gl.h b/src/renderer_gl.h index 60d0f9dca..cd67208a0 100644 --- a/src/renderer_gl.h +++ b/src/renderer_gl.h @@ -457,6 +457,66 @@ typedef uint64_t GLuint64; # define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57 #endif // GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT +#ifndef ATC_RGB_AMD + #define GL_ATC_RGB_AMD 0x8C92 +#endif + +#ifndef GL_ATC_RGBA_EXPLICIT_ALPHA_AMD +# define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 +#endif + +#ifndef ATC_RGBA_INTERPOLATED_ALPHA_AMD +# define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE +#endif + +#ifndef GL_COMPRESSED_RGBA_ASTC_4x4_KHR +# define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#endif + +#ifndef GL_COMPRESSED_RGBA_ASTC_5x5_KHR +# define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#endif + +#ifndef GL_COMPRESSED_RGBA_ASTC_6x6_KHR +# define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#endif + +#ifndef GL_COMPRESSED_RGBA_ASTC_8x5_KHR +# define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#endif + +#ifndef GL_COMPRESSED_RGBA_ASTC_8x6_KHR +# define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#endif + +#ifndef GL_COMPRESSED_RGBA_ASTC_10x5_KHR +# define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#endif + +#ifndef GL_COMPRESSED_SRGB8_ASTC_4x4_KHR +# define GL_COMPRESSED_SRGB8_ASTC_4x4_KHR 0x93D0 +#endif + +#ifndef GL_COMPRESSED_SRGB8_ASTC_5x5_KHR +# define GL_COMPRESSED_SRGB8_ASTC_5x5_KHR 0x93D2 +#endif + +#ifndef GL_COMPRESSED_SRGB8_ASTC_6x6_KHR +# define GL_COMPRESSED_SRGB8_ASTC_6x6_KHR 0x93D4 +#endif + +#ifndef GL_COMPRESSED_SRGB8_ASTC_8x5_KHR +# define GL_COMPRESSED_SRGB8_ASTC_8x5_KHR 0x93D5 +#endif + +#ifndef GL_COMPRESSED_SRGB8_ASTC_8x6_KHR +# define GL_COMPRESSED_SRGB8_ASTC_8x6_KHR 0x93D6 +#endif + +#ifndef GL_COMPRESSED_SRGB8_ASTC_10x5_KHR +# define GL_COMPRESSED_SRGB8_ASTC_10x5_KHR 0x93D8 +#endif + #ifndef GL_COMPRESSED_RGBA_BPTC_UNORM_ARB # define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C #endif // GL_COMPRESSED_RGBA_BPTC_UNORM_ARB diff --git a/src/renderer_mtl.mm b/src/renderer_mtl.mm index d4acba735..f8ba20740 100644 --- a/src/renderer_mtl.mm +++ b/src/renderer_mtl.mm @@ -262,6 +262,24 @@ namespace bgfx { namespace mtl { MTLPixelFormat(166/*PVRTC_RGBA_4BPP*/), MTLPixelFormat(167/*PVRTC_RGBA_4BPP_sRGB*/) }, // PTC14A { MTLPixelFormatInvalid, MTLPixelFormatInvalid }, // PTC22 { MTLPixelFormatInvalid, MTLPixelFormatInvalid }, // PTC24 + { MTLPixelFormatInvalid, MTLPixelFormatInvalid }, // ATC + { MTLPixelFormatInvalid, MTLPixelFormatInvalid }, // ATCE + { MTLPixelFormatInvalid, MTLPixelFormatInvalid }, // ATCI +#if BX_PLATFORM_IOS + { MTLPixelFormatASTC_4x4_LDR, MTLPixelFormatASTC_4x4_sRGB }, // ASTC4x4 + { MTLPixelFormatASTC_5x5_LDR, MTLPixelFormatASTC_5x5_sRGB }, // ASTC5x5 + { MTLPixelFormatASTC_6x6_LDR, MTLPixelFormatASTC_6x6_sRGB }, // ASTC6x6 + { MTLPixelFormatASTC_8x5_LDR, MTLPixelFormatASTC_8x5_sRGB }, // ASTC8x5 + { MTLPixelFormatASTC_8x6_LDR, MTLPixelFormatASTC_8x6_sRGB }, // ASTC8x6 + { MTLPixelFormatASTC_10x5_LDR, MTLPixelFormatASTC_10x5_sRGB }, // ASTC10x5 +#else + { MTLPixelFormatInvalid, MTLPixelFormatInvalid }, // ASTC4x4 + { MTLPixelFormatInvalid, MTLPixelFormatInvalid }, // ASTC5x5 + { MTLPixelFormatInvalid, MTLPixelFormatInvalid }, // ASTC6x6 + { MTLPixelFormatInvalid, MTLPixelFormatInvalid }, // ASTC8x5 + { MTLPixelFormatInvalid, MTLPixelFormatInvalid }, // ASTC8x6 + { MTLPixelFormatInvalid, MTLPixelFormatInvalid }, // ASTC10x5 +#endif { MTLPixelFormatInvalid, MTLPixelFormatInvalid }, // Unknown { MTLPixelFormatInvalid, MTLPixelFormatInvalid }, // R1 { MTLPixelFormatA8Unorm, MTLPixelFormatInvalid }, // A8