|
|
@@ -259,4 +259,270 @@ GLenum convertBlendFactor(BlendFactor in)
|
|
|
return out;
|
|
|
}
|
|
|
|
|
|
+void convertTextureInformation(const PixelFormat& pf,
|
|
|
+ Bool8& compressed,
|
|
|
+ GLenum& format,
|
|
|
+ GLenum& internalFormat,
|
|
|
+ GLenum& type,
|
|
|
+ DepthStencilAspectBit& dsAspect)
|
|
|
+{
|
|
|
+ compressed =
|
|
|
+ pf.m_components >= ComponentFormat::FIRST_COMPRESSED && pf.m_components <= ComponentFormat::LAST_COMPRESSED;
|
|
|
+
|
|
|
+ switch(pf.m_components)
|
|
|
+ {
|
|
|
+#if ANKI_GL == ANKI_GL_DESKTOP
|
|
|
+ case ComponentFormat::R8G8B8_S3TC:
|
|
|
+ format = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
|
|
|
+ internalFormat = format;
|
|
|
+ type = GL_UNSIGNED_BYTE;
|
|
|
+ break;
|
|
|
+ case ComponentFormat::R8G8B8A8_S3TC:
|
|
|
+ format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
|
|
+ internalFormat = format;
|
|
|
+ type = GL_UNSIGNED_BYTE;
|
|
|
+ break;
|
|
|
+#else
|
|
|
+ case ComponentFormat::R8G8B8_ETC2:
|
|
|
+ format = GL_COMPRESSED_RGB8_ETC2;
|
|
|
+ internalFormat = format;
|
|
|
+ type = GL_UNSIGNED_BYTE;
|
|
|
+ break;
|
|
|
+ case ComponentFormat::R8G8B8A8_ETC2:
|
|
|
+ format = GL_COMPRESSED_RGBA8_ETC2_EAC;
|
|
|
+ internalFormat = format;
|
|
|
+ type = GL_UNSIGNED_BYTE;
|
|
|
+ break;
|
|
|
+#endif
|
|
|
+ case ComponentFormat::R8:
|
|
|
+ format = GL_RED;
|
|
|
+
|
|
|
+ if(pf.m_transform == TransformFormat::UNORM)
|
|
|
+ {
|
|
|
+ internalFormat = GL_R8;
|
|
|
+ type = GL_UNSIGNED_BYTE;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ANKI_ASSERT(pf.m_transform == TransformFormat::SNORM);
|
|
|
+ internalFormat = GL_R8_SNORM;
|
|
|
+ type = GL_BYTE;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ComponentFormat::R8G8:
|
|
|
+ format = GL_RG;
|
|
|
+
|
|
|
+ if(pf.m_transform == TransformFormat::UNORM)
|
|
|
+ {
|
|
|
+ internalFormat = GL_RG8;
|
|
|
+ type = GL_UNSIGNED_BYTE;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ANKI_ASSERT(pf.m_transform == TransformFormat::SNORM);
|
|
|
+ internalFormat = GL_RG8_SNORM;
|
|
|
+ type = GL_BYTE;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ComponentFormat::R8G8B8:
|
|
|
+ format = GL_RGB;
|
|
|
+
|
|
|
+ if(pf.m_transform == TransformFormat::UNORM)
|
|
|
+ {
|
|
|
+ internalFormat = GL_RGB8;
|
|
|
+ type = GL_UNSIGNED_BYTE;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ANKI_ASSERT(pf.m_transform == TransformFormat::SNORM);
|
|
|
+ internalFormat = GL_RGB8_SNORM;
|
|
|
+ type = GL_BYTE;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ComponentFormat::R8G8B8A8:
|
|
|
+ format = GL_RGBA;
|
|
|
+
|
|
|
+ if(pf.m_transform == TransformFormat::UNORM)
|
|
|
+ {
|
|
|
+ internalFormat = GL_RGBA8;
|
|
|
+ type = GL_UNSIGNED_BYTE;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ANKI_ASSERT(pf.m_transform == TransformFormat::SNORM);
|
|
|
+ internalFormat = GL_RGBA8_SNORM;
|
|
|
+ type = GL_BYTE;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ComponentFormat::R16:
|
|
|
+ if(pf.m_transform == TransformFormat::FLOAT)
|
|
|
+ {
|
|
|
+ format = GL_R;
|
|
|
+ internalFormat = GL_R16F;
|
|
|
+ type = GL_FLOAT;
|
|
|
+ }
|
|
|
+ else if(pf.m_transform == TransformFormat::UINT)
|
|
|
+ {
|
|
|
+ format = GL_R;
|
|
|
+ internalFormat = GL_R16UI;
|
|
|
+ type = GL_UNSIGNED_INT;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ANKI_ASSERT(!"TODO");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ComponentFormat::R16G16B16:
|
|
|
+ if(pf.m_transform == TransformFormat::FLOAT)
|
|
|
+ {
|
|
|
+ format = GL_RGB;
|
|
|
+ internalFormat = GL_RGB16F;
|
|
|
+ type = GL_FLOAT;
|
|
|
+ }
|
|
|
+ else if(pf.m_transform == TransformFormat::UINT)
|
|
|
+ {
|
|
|
+ format = GL_RGB_INTEGER;
|
|
|
+ internalFormat = GL_RGB16UI;
|
|
|
+ type = GL_UNSIGNED_INT;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ANKI_ASSERT(0 && "TODO");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ComponentFormat::R16G16B16A16:
|
|
|
+ if(pf.m_transform == TransformFormat::FLOAT)
|
|
|
+ {
|
|
|
+ format = GL_RGBA;
|
|
|
+ internalFormat = GL_RGBA16F;
|
|
|
+ type = GL_FLOAT;
|
|
|
+ }
|
|
|
+ else if(pf.m_transform == TransformFormat::UINT)
|
|
|
+ {
|
|
|
+ ANKI_ASSERT(!"TODO");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ANKI_ASSERT(!"TODO");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ComponentFormat::R32:
|
|
|
+ if(pf.m_transform == TransformFormat::FLOAT)
|
|
|
+ {
|
|
|
+ format = GL_R;
|
|
|
+ internalFormat = GL_R32F;
|
|
|
+ type = GL_FLOAT;
|
|
|
+ }
|
|
|
+ else if(pf.m_transform == TransformFormat::UINT)
|
|
|
+ {
|
|
|
+ format = GL_RG_INTEGER;
|
|
|
+ internalFormat = GL_R32UI;
|
|
|
+ type = GL_UNSIGNED_INT;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ANKI_ASSERT(0 && "TODO");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ComponentFormat::R32G32:
|
|
|
+ if(pf.m_transform == TransformFormat::FLOAT)
|
|
|
+ {
|
|
|
+ format = GL_RG;
|
|
|
+ internalFormat = GL_RG32F;
|
|
|
+ type = GL_FLOAT;
|
|
|
+ }
|
|
|
+ else if(pf.m_transform == TransformFormat::UINT)
|
|
|
+ {
|
|
|
+ format = GL_RG_INTEGER;
|
|
|
+ internalFormat = GL_RG32UI;
|
|
|
+ type = GL_UNSIGNED_INT;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ANKI_ASSERT(0 && "TODO");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ComponentFormat::R32G32B32:
|
|
|
+ if(pf.m_transform == TransformFormat::FLOAT)
|
|
|
+ {
|
|
|
+ format = GL_RGB;
|
|
|
+ internalFormat = GL_RGB32F;
|
|
|
+ type = GL_FLOAT;
|
|
|
+ }
|
|
|
+ else if(pf.m_transform == TransformFormat::UINT)
|
|
|
+ {
|
|
|
+ format = GL_RGB_INTEGER;
|
|
|
+ internalFormat = GL_RGB32UI;
|
|
|
+ type = GL_UNSIGNED_INT;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ANKI_ASSERT(!"TODO");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ComponentFormat::R32G32B32A32:
|
|
|
+ if(pf.m_transform == TransformFormat::FLOAT)
|
|
|
+ {
|
|
|
+ format = GL_RGBA;
|
|
|
+ internalFormat = GL_RGBA32F;
|
|
|
+ type = GL_FLOAT;
|
|
|
+ }
|
|
|
+ else if(pf.m_transform == TransformFormat::UINT)
|
|
|
+ {
|
|
|
+ format = GL_RGBA_INTEGER;
|
|
|
+ internalFormat = GL_RGBA32UI;
|
|
|
+ type = GL_UNSIGNED_INT;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ANKI_ASSERT(!"TODO");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ComponentFormat::R11G11B10:
|
|
|
+ if(pf.m_transform == TransformFormat::FLOAT)
|
|
|
+ {
|
|
|
+ format = GL_RGB;
|
|
|
+ internalFormat = GL_R11F_G11F_B10F;
|
|
|
+ type = GL_FLOAT;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ANKI_ASSERT(0 && "TODO");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ComponentFormat::R10G10B10A2:
|
|
|
+ if(pf.m_transform == TransformFormat::UNORM)
|
|
|
+ {
|
|
|
+ format = GL_RGBA;
|
|
|
+ internalFormat = GL_RGB10_A2;
|
|
|
+ type = GL_UNSIGNED_INT;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ANKI_ASSERT(0 && "TODO");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ComponentFormat::D24S8:
|
|
|
+ format = GL_DEPTH_STENCIL;
|
|
|
+ internalFormat = GL_DEPTH24_STENCIL8;
|
|
|
+ type = GL_UNSIGNED_INT;
|
|
|
+ dsAspect = DepthStencilAspectBit::DEPTH_STENCIL;
|
|
|
+ break;
|
|
|
+ case ComponentFormat::D16:
|
|
|
+ format = GL_DEPTH_COMPONENT;
|
|
|
+ internalFormat = GL_DEPTH_COMPONENT16;
|
|
|
+ type = GL_UNSIGNED_SHORT;
|
|
|
+ dsAspect = DepthStencilAspectBit::DEPTH;
|
|
|
+ break;
|
|
|
+ case ComponentFormat::S8:
|
|
|
+ format = GL_STENCIL_INDEX;
|
|
|
+ internalFormat = GL_STENCIL_INDEX8;
|
|
|
+ type = GL_BYTE;
|
|
|
+ dsAspect = DepthStencilAspectBit::STENCIL;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ ANKI_ASSERT(0);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
} // end namespace anki
|