mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-20 17:20:26 +01:00
Merging r6039 through r6072 from trunk to ogl-es branch.
Note: Not yet caught up with trunk. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6114 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
3e26f3d7a9
commit
cb62c685de
@ -9,6 +9,7 @@ Changes in ogl-es (not yet released - will be merged with trunk at some point)
|
||||
|
||||
--------------------------
|
||||
Changes in 1.9 (not yet released)
|
||||
- Fix CPLYMeshFileLoader checking for wrong vertex count when switching between 16/32 bit. Thanks @randomMesh for reporting.
|
||||
- Fix bug that AnimatedMeshSceneNode ignored ReadOnlyMaterials flag when checking materials for transparent render passes.
|
||||
- Unify checks if materials should use transparent render pass with new IVideoDriver::needsTransparentRenderPass function.
|
||||
- Material.ZWriteEnable is now of type E_ZWRITE instead of bool. This allows now setting materials to always "on" independent of material type and transparency.
|
||||
|
@ -243,11 +243,11 @@ public:
|
||||
++i;
|
||||
if ( mipSize.Width == 1 && mipSize.Height == 1 && i < mipLevel)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return MipMapsData + dataSize;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -470,25 +470,29 @@ public:
|
||||
return imageSize;
|
||||
}
|
||||
|
||||
// Define to check for all compressed image formats cases in a switch
|
||||
#define IRR_CASE_IIMAGE_COMPRESSED_FORMAT\
|
||||
case ECF_DXT1:\
|
||||
case ECF_DXT2:\
|
||||
case ECF_DXT3:\
|
||||
case ECF_DXT4:\
|
||||
case ECF_DXT5:\
|
||||
case ECF_PVRTC_RGB2:\
|
||||
case ECF_PVRTC_ARGB2:\
|
||||
case ECF_PVRTC2_ARGB2:\
|
||||
case ECF_PVRTC_RGB4:\
|
||||
case ECF_PVRTC_ARGB4:\
|
||||
case ECF_PVRTC2_ARGB4:\
|
||||
case ECF_ETC1:\
|
||||
case ECF_ETC2_RGB:\
|
||||
case ECF_ETC2_ARGB:
|
||||
|
||||
//! check if this is compressed color format
|
||||
static bool isCompressedFormat(const ECOLOR_FORMAT format)
|
||||
{
|
||||
switch(format)
|
||||
{
|
||||
case ECF_DXT1:
|
||||
case ECF_DXT2:
|
||||
case ECF_DXT3:
|
||||
case ECF_DXT4:
|
||||
case ECF_DXT5:
|
||||
case ECF_PVRTC_RGB2:
|
||||
case ECF_PVRTC_ARGB2:
|
||||
case ECF_PVRTC2_ARGB2:
|
||||
case ECF_PVRTC_RGB4:
|
||||
case ECF_PVRTC_ARGB4:
|
||||
case ECF_PVRTC2_ARGB4:
|
||||
case ECF_ETC1:
|
||||
case ECF_ETC2_RGB:
|
||||
case ECF_ETC2_ARGB:
|
||||
IRR_CASE_IIMAGE_COMPRESSED_FORMAT
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -757,8 +757,13 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN
|
||||
case ECF_R8G8B8:
|
||||
convert_A1R5G5B5toR8G8B8(sP, sN, dP);
|
||||
break;
|
||||
IRR_CASE_IIMAGE_COMPRESSED_FORMAT
|
||||
os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING);
|
||||
break;
|
||||
#ifndef _DEBUG
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case ECF_R5G6B5:
|
||||
@ -776,8 +781,13 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN
|
||||
case ECF_R8G8B8:
|
||||
convert_R5G6B5toR8G8B8(sP, sN, dP);
|
||||
break;
|
||||
IRR_CASE_IIMAGE_COMPRESSED_FORMAT
|
||||
os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING);
|
||||
break;
|
||||
#ifndef _DEBUG
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case ECF_A8R8G8B8:
|
||||
@ -795,8 +805,13 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN
|
||||
case ECF_R8G8B8:
|
||||
convert_A8R8G8B8toR8G8B8(sP, sN, dP);
|
||||
break;
|
||||
IRR_CASE_IIMAGE_COMPRESSED_FORMAT
|
||||
os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING);
|
||||
break;
|
||||
#ifndef _DEBUG
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case ECF_R8G8B8:
|
||||
@ -814,10 +829,18 @@ void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN
|
||||
case ECF_R8G8B8:
|
||||
convert_R8G8B8toR8G8B8(sP, sN, dP);
|
||||
break;
|
||||
IRR_CASE_IIMAGE_COMPRESSED_FORMAT
|
||||
os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING);
|
||||
break;
|
||||
#ifndef _DEBUG
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
IRR_CASE_IIMAGE_COMPRESSED_FORMAT
|
||||
os::Printer::log("CColorConverter::convert_viaFormat method doesn't support compressed images.", ELL_WARNING);
|
||||
break;
|
||||
#ifndef _DEBUG
|
||||
default:
|
||||
break;
|
||||
|
@ -3270,6 +3270,9 @@ ITexture* CD3D9Driver::addRenderTargetTexture(const core::dimension2d<u32>& size
|
||||
const io::path& name,
|
||||
const ECOLOR_FORMAT format)
|
||||
{
|
||||
if ( IImage::isCompressedFormat(format) )
|
||||
return 0;
|
||||
|
||||
CD3D9Texture* tex = new CD3D9Texture(this, size, name, ETT_2D, format);
|
||||
if (tex)
|
||||
{
|
||||
@ -3288,6 +3291,9 @@ ITexture* CD3D9Driver::addRenderTargetTexture(const core::dimension2d<u32>& size
|
||||
ITexture* CD3D9Driver::addRenderTargetTextureCubemap(const irr::u32 sideLen,
|
||||
const io::path& name, const ECOLOR_FORMAT format)
|
||||
{
|
||||
if ( IImage::isCompressedFormat(format) )
|
||||
return 0;
|
||||
|
||||
CD3D9Texture* tex = new CD3D9Texture(this, core::dimension2d<u32>(sideLen, sideLen), name, ETT_CUBEMAP, format);
|
||||
if (tex)
|
||||
{
|
||||
|
@ -43,12 +43,6 @@ CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size) : IImag
|
||||
//! sets a pixel
|
||||
void CImage::setPixel(u32 x, u32 y, const SColor &color, bool blend)
|
||||
{
|
||||
if (IImage::isCompressedFormat(Format))
|
||||
{
|
||||
os::Printer::log("IImage::setPixel method doesn't work with compressed images.", ELL_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
if (x >= Size.Width || y >= Size.Height)
|
||||
return;
|
||||
|
||||
@ -79,6 +73,15 @@ void CImage::setPixel(u32 x, u32 y, const SColor &color, bool blend)
|
||||
u32 * dest = (u32*) (Data + ( y * Pitch ) + ( x << 2 ));
|
||||
*dest = blend ? PixelBlend32 ( *dest, color.color ) : color.color;
|
||||
} break;
|
||||
|
||||
IRR_CASE_IIMAGE_COMPRESSED_FORMAT
|
||||
os::Printer::log("IImage::setPixel method doesn't work with compressed images.", ELL_WARNING);
|
||||
return;
|
||||
|
||||
case ECF_UNKNOWN:
|
||||
os::Printer::log("IImage::setPixel unknown format.", ELL_WARNING);
|
||||
return;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -88,12 +91,6 @@ void CImage::setPixel(u32 x, u32 y, const SColor &color, bool blend)
|
||||
//! returns a pixel
|
||||
SColor CImage::getPixel(u32 x, u32 y) const
|
||||
{
|
||||
if (IImage::isCompressedFormat(Format))
|
||||
{
|
||||
os::Printer::log("IImage::getPixel method doesn't work with compressed images.", ELL_WARNING);
|
||||
return SColor(0);
|
||||
}
|
||||
|
||||
if (x >= Size.Width || y >= Size.Height)
|
||||
return SColor(0);
|
||||
|
||||
@ -110,6 +107,15 @@ SColor CImage::getPixel(u32 x, u32 y) const
|
||||
u8* p = Data+(y*3)*Size.Width + (x*3);
|
||||
return SColor(255,p[0],p[1],p[2]);
|
||||
}
|
||||
|
||||
IRR_CASE_IIMAGE_COMPRESSED_FORMAT
|
||||
os::Printer::log("IImage::getPixel method doesn't work with compressed images.", ELL_WARNING);
|
||||
break;
|
||||
|
||||
case ECF_UNKNOWN:
|
||||
os::Printer::log("IImage::getPixel unknown format.", ELL_WARNING);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -127,7 +133,7 @@ void CImage::copyTo(IImage* target, const core::position2d<s32>& pos)
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !Blit(BLITTER_TEXTURE, target, 0, &pos, this, 0, 0)
|
||||
if ( !Blit(BLITTER_TEXTURE, target, 0, &pos, this, 0, 0)
|
||||
&& target && pos.X == 0 && pos.Y == 0 &&
|
||||
CColorConverter::canConvertFormat(Format, target->getColorFormat()) )
|
||||
{
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "IWriteFile.h"
|
||||
#include "CColorConverter.h"
|
||||
#include "irrString.h"
|
||||
#include "os.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
@ -81,6 +82,7 @@ bool CImageWriterBMP::writeImage(io::IWriteFile* file, IImage* image, u32 param)
|
||||
= CColorConverter::convert_R5G6B5toR8G8B8;
|
||||
break;
|
||||
default:
|
||||
os::Printer::log("CImageWriterBMP does not support image format", ColorFormatNames[image->getColorFormat()], ELL_WARNING);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "IWriteFile.h"
|
||||
#include "CImage.h"
|
||||
#include "irrString.h"
|
||||
#include "os.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_LIBJPEG_
|
||||
#include <stdio.h> // required for jpeglib.h
|
||||
@ -122,6 +123,7 @@ static bool writeJPEGFile(io::IWriteFile* file, IImage* image, u32 quality)
|
||||
format = CColorConverter::convert_R5G6B5toR8G8B8;
|
||||
break;
|
||||
default:
|
||||
os::Printer::log("writeJPEGFile does not support image format", ColorFormatNames[image->getColorFormat()], ELL_WARNING);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,10 @@ bool CImageWriterPNG::writeImage(io::IWriteFile* file, IImage* image,u32 param)
|
||||
break;
|
||||
// TODO: Error handling in case of unsupported color format
|
||||
default:
|
||||
break;
|
||||
os::Printer::log("CImageWriterPNG does not support image format", ColorFormatNames[image->getColorFormat()], ELL_WARNING);
|
||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||
delete [] tmpImage;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create array of pointers to rows in image data
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "IWriteFile.h"
|
||||
#include "CColorConverter.h"
|
||||
#include "irrString.h"
|
||||
#include "os.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
@ -85,6 +86,7 @@ bool CImageWriterTGA::writeImage(io::IWriteFile *file, IImage *image,u32 param)
|
||||
imageHeader.ImageDescriptor |= 0;
|
||||
break;
|
||||
default:
|
||||
os::Printer::log("CImageWriterTGA does not support image format", ColorFormatNames[image->getColorFormat()], ELL_WARNING);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -274,6 +274,9 @@ public:
|
||||
AssignedDepth = false;
|
||||
AssignedStencil = false;
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
Driver->testGLError(__LINE__);
|
||||
#endif
|
||||
|
||||
RequestDepthStencilUpdate = false;
|
||||
}
|
||||
|
@ -2752,7 +2752,7 @@ void COpenGLDriver::setTextureRenderStates(const SMaterial& material, bool reset
|
||||
statesCache.IsCached = false;
|
||||
|
||||
#ifdef GL_VERSION_2_1
|
||||
if (Version >= 210)
|
||||
if (Version >= 201)
|
||||
{
|
||||
if (!statesCache.IsCached || material.TextureLayer[i].LODBias != statesCache.LODBias)
|
||||
{
|
||||
@ -3772,6 +3772,9 @@ IVideoDriver* COpenGLDriver::getVideoDriver()
|
||||
ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d<u32>& size,
|
||||
const io::path& name, const ECOLOR_FORMAT format)
|
||||
{
|
||||
if ( IImage::isCompressedFormat(format) )
|
||||
return 0;
|
||||
|
||||
//disable mip-mapping
|
||||
bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS);
|
||||
setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false);
|
||||
@ -3799,6 +3802,9 @@ ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d<u32>& si
|
||||
//! Creates a render target texture for a cubemap
|
||||
ITexture* COpenGLDriver::addRenderTargetTextureCubemap(const irr::u32 sideLen, const io::path& name, const ECOLOR_FORMAT format)
|
||||
{
|
||||
if ( IImage::isCompressedFormat(format) )
|
||||
return 0;
|
||||
|
||||
//disable mip-mapping
|
||||
bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS);
|
||||
setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false);
|
||||
@ -4231,10 +4237,13 @@ bool COpenGLDriver::getColorFormatParameters(ECOLOR_FORMAT format, GLint& intern
|
||||
pixelType = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
break;
|
||||
case ECF_DXT1:
|
||||
supported = true;
|
||||
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
pixelFormat = GL_BGRA_EXT;
|
||||
pixelType = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
if (queryOpenGLFeature(COpenGLExtensionHandler::IRR_EXT_texture_compression_s3tc))
|
||||
{
|
||||
supported = true;
|
||||
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
pixelFormat = GL_BGRA_EXT;
|
||||
pixelType = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
}
|
||||
break;
|
||||
case ECF_DXT2:
|
||||
case ECF_DXT3:
|
||||
|
@ -44,7 +44,9 @@ COpenGLExtensionHandler::COpenGLExtensionHandler() :
|
||||
pGlGetUniformLocationARB(0), pGlGetUniformLocation(0),
|
||||
pGlUniform1fvARB(0), pGlUniform2fvARB(0), pGlUniform3fvARB(0), pGlUniform4fvARB(0),
|
||||
pGlUniform1ivARB(0), pGlUniform2ivARB(0), pGlUniform3ivARB(0), pGlUniform4ivARB(0),
|
||||
pGlUniformMatrix2fvARB(0), pGlUniformMatrix3fvARB(0), pGlUniformMatrix4fvARB(0),
|
||||
pGlUniformMatrix2fvARB(0), pGlUniformMatrix2x3fv(0), pGlUniformMatrix2x4fv(0),
|
||||
pGlUniformMatrix3x2fv(0), pGlUniformMatrix3fvARB(0), pGlUniformMatrix3x4fv(0),
|
||||
pGlUniformMatrix4x2fv(0), pGlUniformMatrix4x3fv(0), pGlUniformMatrix4fvARB(0),
|
||||
pGlGetActiveUniformARB(0), pGlGetActiveUniform(0),
|
||||
pGlPointParameterfARB(0), pGlPointParameterfvARB(0),
|
||||
pGlStencilFuncSeparate(0), pGlStencilOpSeparate(0),
|
||||
@ -84,11 +86,11 @@ COpenGLExtensionHandler::COpenGLExtensionHandler() :
|
||||
pGlBlendFuncIndexedAMD(0), pGlBlendFunciARB(0), pGlBlendFuncSeparateIndexedAMD(0), pGlBlendFuncSeparateiARB(0),
|
||||
pGlBlendEquationIndexedAMD(0), pGlBlendEquationiARB(0), pGlBlendEquationSeparateIndexedAMD(0), pGlBlendEquationSeparateiARB(0),
|
||||
// DSA
|
||||
pGlTextureStorage2D(0), pGlTextureStorage3D(0), pGlTextureSubImage2D(0), pGlNamedFramebufferTexture(0),
|
||||
pGlTextureStorage2D(0), pGlTextureStorage3D(0), pGlTextureSubImage2D(0), pGlGetTextureImage(0), pGlNamedFramebufferTexture(0),
|
||||
pGlTextureParameteri(0), pGlCreateTextures(0), pGlCreateFramebuffers(0), pGlBindTextures(0), pGlGenerateTextureMipmap(0),
|
||||
// DSA with EXT or functions to simulate it
|
||||
pGlTextureSubImage2DEXT(0), pGlTextureStorage2DEXT(0), pGlTexStorage2D(0), pGlTextureStorage3DEXT(0),
|
||||
pGlTexStorage3D(0), pGlNamedFramebufferTextureEXT(0), pGlFramebufferTexture(0), pGlGenerateTextureMipmapEXT(0)
|
||||
pGlTextureStorage2DEXT(0), pGlTexStorage2D(0), pGlTextureStorage3DEXT(0), pGlTexStorage3D(0), pGlTextureSubImage2DEXT(0), pGlGetTextureImageEXT(0),
|
||||
pGlNamedFramebufferTextureEXT(0), pGlFramebufferTexture(0), pGlGenerateTextureMipmapEXT(0)
|
||||
#if defined(GLX_SGI_swap_control)
|
||||
,pGlxSwapIntervalSGI(0)
|
||||
#endif
|
||||
@ -465,7 +467,13 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
|
||||
pGlUniform3ivARB = (PFNGLUNIFORM3IVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniform3ivARB");
|
||||
pGlUniform4ivARB = (PFNGLUNIFORM4IVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniform4ivARB");
|
||||
pGlUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniformMatrix2fvARB");
|
||||
pGlUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC) IRR_OGL_LOAD_EXTENSION("glUniformMatrix2x3fv");
|
||||
pGlUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix2x4fv");
|
||||
pGlUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix3x2fv");
|
||||
pGlUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniformMatrix3fvARB");
|
||||
pGlUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix3x4fv");
|
||||
pGlUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix4x2fv");
|
||||
pGlUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC)IRR_OGL_LOAD_EXTENSION("glUniformMatrix4x3fv");
|
||||
pGlUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC) IRR_OGL_LOAD_EXTENSION("glUniformMatrix4fvARB");
|
||||
pGlGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC) IRR_OGL_LOAD_EXTENSION("glGetActiveUniformARB");
|
||||
pGlGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC) IRR_OGL_LOAD_EXTENSION("glGetActiveUniform");
|
||||
@ -567,9 +575,10 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
|
||||
pGlBlendEquationSeparateIndexedAMD = (PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) IRR_OGL_LOAD_EXTENSION("glBlendEquationSeparateIndexedAMD");
|
||||
pGlBlendEquationSeparateiARB = (PFNGLBLENDEQUATIONSEPARATEIPROC) IRR_OGL_LOAD_EXTENSION("glBlendEquationSeparateiARB");
|
||||
|
||||
pGlTextureSubImage2D = (PFNGLTEXTURESUBIMAGE2DPROC)IRR_OGL_LOAD_EXTENSION("glTextureSubImage2D");
|
||||
pGlTextureStorage2D = (PFNGLTEXTURESTORAGE2DPROC) IRR_OGL_LOAD_EXTENSION("glTextureStorage2D");
|
||||
pGlTextureStorage3D = (PFNGLTEXTURESTORAGE3DPROC) IRR_OGL_LOAD_EXTENSION("glTextureStorage3D");
|
||||
pGlTextureSubImage2D = (PFNGLTEXTURESUBIMAGE2DPROC)IRR_OGL_LOAD_EXTENSION("glTextureSubImage2D");
|
||||
pGlGetTextureImage = (PFNGLGETTEXTUREIMAGEPROC)IRR_OGL_LOAD_EXTENSION("glGetTextureImage");
|
||||
pGlNamedFramebufferTexture = (PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) IRR_OGL_LOAD_EXTENSION("glNamedFramebufferTexture");
|
||||
pGlTextureParameteri = (PFNGLTEXTUREPARAMETERIPROC) IRR_OGL_LOAD_EXTENSION("glTextureParameteri");
|
||||
pGlCreateTextures = (PFNGLCREATETEXTURESPROC) IRR_OGL_LOAD_EXTENSION("glCreateTextures");
|
||||
@ -577,11 +586,12 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
|
||||
pGlBindTextures = (PFNGLBINDTEXTURESPROC) IRR_OGL_LOAD_EXTENSION("glBindTextures");
|
||||
pGlGenerateTextureMipmap = (PFNGLGENERATETEXTUREMIPMAPPROC) IRR_OGL_LOAD_EXTENSION("glGenerateTextureMipmap");
|
||||
//==============================
|
||||
pGlTextureSubImage2DEXT = (PFNGLTEXTURESUBIMAGE2DEXTPROC)IRR_OGL_LOAD_EXTENSION("glTextureSubImage2DEXT");
|
||||
pGlTextureStorage2DEXT = (PFNGLTEXTURESTORAGE2DEXTPROC)IRR_OGL_LOAD_EXTENSION("glTextureStorage2DEXT");
|
||||
pGlTexStorage2D = (PFNGLTEXSTORAGE2DPROC)IRR_OGL_LOAD_EXTENSION("glTexStorage2D");
|
||||
pGlTextureStorage3DEXT = (PFNGLTEXTURESTORAGE3DEXTPROC)IRR_OGL_LOAD_EXTENSION("glTextureStorage3DEXT");
|
||||
pGlTexStorage3D = (PFNGLTEXSTORAGE3DPROC)IRR_OGL_LOAD_EXTENSION("glTexStorage3D");
|
||||
pGlTextureSubImage2DEXT = (PFNGLTEXTURESUBIMAGE2DEXTPROC)IRR_OGL_LOAD_EXTENSION("glTextureSubImage2DEXT");
|
||||
pGlGetTextureImageEXT = (PFNGLGETTEXTUREIMAGEEXTPROC)IRR_OGL_LOAD_EXTENSION("glGetTextureImageEXT");
|
||||
pGlNamedFramebufferTextureEXT = (PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC)IRR_OGL_LOAD_EXTENSION("glNamedFramebufferTextureEXT");
|
||||
pGlFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)IRR_OGL_LOAD_EXTENSION("glFramebufferTexture");
|
||||
pGlActiveTexture = (PFNGLACTIVETEXTUREPROC)IRR_OGL_LOAD_EXTENSION("glActiveTexture");
|
||||
@ -751,7 +761,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
|
||||
#endif
|
||||
OcclusionQuerySupport=false;
|
||||
|
||||
Feature.BlendOperation = (Version >= 140) ||
|
||||
Feature.BlendOperation = (Version >= 104) ||
|
||||
FeatureAvailable[IRR_EXT_blend_minmax] ||
|
||||
FeatureAvailable[IRR_EXT_blend_subtract] ||
|
||||
FeatureAvailable[IRR_EXT_blend_logic_op];
|
||||
@ -850,17 +860,17 @@ bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
|
||||
return FeatureAvailable[IRR_ARB_occlusion_query] && OcclusionQuerySupport;
|
||||
case EVDF_POLYGON_OFFSET:
|
||||
// both features supported with OpenGL 1.1
|
||||
return Version>=110;
|
||||
return Version>=101;
|
||||
case EVDF_BLEND_OPERATIONS:
|
||||
return Feature.BlendOperation;
|
||||
case EVDF_BLEND_SEPARATE:
|
||||
return (Version>=140) || FeatureAvailable[IRR_EXT_blend_func_separate];
|
||||
return (Version>=104) || FeatureAvailable[IRR_EXT_blend_func_separate];
|
||||
case EVDF_TEXTURE_MATRIX:
|
||||
return true;
|
||||
case EVDF_TEXTURE_COMPRESSED_DXT:
|
||||
return FeatureAvailable[IRR_EXT_texture_compression_s3tc];
|
||||
case EVDF_TEXTURE_CUBEMAP:
|
||||
return (Version >= 130) || FeatureAvailable[IRR_ARB_texture_cube_map] || FeatureAvailable[IRR_EXT_texture_cube_map];
|
||||
return (Version >= 103) || FeatureAvailable[IRR_ARB_texture_cube_map] || FeatureAvailable[IRR_EXT_texture_cube_map];
|
||||
case EVDF_TEXTURE_CUBEMAP_SEAMLESS:
|
||||
return FeatureAvailable[IRR_ARB_seamless_cube_map];
|
||||
case EVDF_DEPTH_CLAMP:
|
||||
|
@ -85,6 +85,7 @@ static const char* const OpenGLFeatureStrings[] = {
|
||||
"GL_ARB_depth_buffer_float",
|
||||
"GL_ARB_depth_clamp",
|
||||
"GL_ARB_depth_texture",
|
||||
"GL_ARB_direct_state_access",
|
||||
"GL_ARB_draw_buffers",
|
||||
"GL_ARB_draw_buffers_blend",
|
||||
"GL_ARB_draw_elements_base_vertex",
|
||||
@ -571,6 +572,7 @@ class COpenGLExtensionHandler
|
||||
IRR_ARB_depth_buffer_float,
|
||||
IRR_ARB_depth_clamp,
|
||||
IRR_ARB_depth_texture,
|
||||
IRR_ARB_direct_state_access,
|
||||
IRR_ARB_draw_buffers,
|
||||
IRR_ARB_draw_buffers_blend,
|
||||
IRR_ARB_draw_elements_base_vertex,
|
||||
@ -1126,7 +1128,13 @@ class COpenGLExtensionHandler
|
||||
void extGlUniform3iv(GLint loc, GLsizei count, const GLint *v);
|
||||
void extGlUniform4iv(GLint loc, GLsizei count, const GLint *v);
|
||||
void extGlUniformMatrix2fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v);
|
||||
void extGlUniformMatrix2x3fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v);
|
||||
void extGlUniformMatrix2x4fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v);
|
||||
void extGlUniformMatrix3x2fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v);
|
||||
void extGlUniformMatrix3fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v);
|
||||
void extGlUniformMatrix3x4fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v);
|
||||
void extGlUniformMatrix4x2fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v);
|
||||
void extGlUniformMatrix4x3fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v);
|
||||
void extGlUniformMatrix4fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v);
|
||||
void extGlGetActiveUniformARB(GLhandleARB program, GLuint index, GLsizei maxlength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
|
||||
void extGlGetActiveUniform(GLuint program, GLuint index, GLsizei maxlength, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
|
||||
@ -1188,6 +1196,7 @@ class COpenGLExtensionHandler
|
||||
void extGlTextureSubImage2D(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels);
|
||||
void extGlTextureStorage2D(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
|
||||
void extGlTextureStorage3D(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
|
||||
void extGlGetTextureImage(GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void* pixels);
|
||||
void extGlNamedFramebufferTexture(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);
|
||||
void extGlTextureParameteri(GLuint texture, GLenum pname, GLint param);
|
||||
void extGlCreateTextures(GLenum target, GLsizei n, GLuint* textures);
|
||||
@ -1254,7 +1263,13 @@ class COpenGLExtensionHandler
|
||||
PFNGLUNIFORM3IVARBPROC pGlUniform3ivARB;
|
||||
PFNGLUNIFORM4IVARBPROC pGlUniform4ivARB;
|
||||
PFNGLUNIFORMMATRIX2FVARBPROC pGlUniformMatrix2fvARB;
|
||||
PFNGLUNIFORMMATRIX2X3FVPROC pGlUniformMatrix2x3fv;
|
||||
PFNGLUNIFORMMATRIX2X4FVPROC pGlUniformMatrix2x4fv;
|
||||
PFNGLUNIFORMMATRIX3X2FVPROC pGlUniformMatrix3x2fv;
|
||||
PFNGLUNIFORMMATRIX3FVARBPROC pGlUniformMatrix3fvARB;
|
||||
PFNGLUNIFORMMATRIX3X4FVPROC pGlUniformMatrix3x4fv;
|
||||
PFNGLUNIFORMMATRIX4X2FVPROC pGlUniformMatrix4x2fv;
|
||||
PFNGLUNIFORMMATRIX4X3FVPROC pGlUniformMatrix4x3fv;
|
||||
PFNGLUNIFORMMATRIX4FVARBPROC pGlUniformMatrix4fvARB;
|
||||
PFNGLGETACTIVEUNIFORMARBPROC pGlGetActiveUniformARB;
|
||||
PFNGLGETACTIVEUNIFORMPROC pGlGetActiveUniform;
|
||||
@ -1347,6 +1362,7 @@ class COpenGLExtensionHandler
|
||||
PFNGLTEXTURESTORAGE2DPROC pGlTextureStorage2D;
|
||||
PFNGLTEXTURESTORAGE3DPROC pGlTextureStorage3D;
|
||||
PFNGLTEXTURESUBIMAGE2DPROC pGlTextureSubImage2D;
|
||||
PFNGLGETTEXTUREIMAGEPROC pGlGetTextureImage;
|
||||
PFNGLNAMEDFRAMEBUFFERTEXTUREPROC pGlNamedFramebufferTexture;
|
||||
PFNGLTEXTUREPARAMETERIPROC pGlTextureParameteri;
|
||||
PFNGLCREATETEXTURESPROC pGlCreateTextures;
|
||||
@ -1354,11 +1370,12 @@ class COpenGLExtensionHandler
|
||||
PFNGLBINDTEXTURESPROC pGlBindTextures;
|
||||
PFNGLGENERATETEXTUREMIPMAPPROC pGlGenerateTextureMipmap;
|
||||
// DSA with EXT or functions to simulate it
|
||||
PFNGLTEXTURESUBIMAGE2DEXTPROC pGlTextureSubImage2DEXT;
|
||||
PFNGLTEXTURESTORAGE2DEXTPROC pGlTextureStorage2DEXT;
|
||||
PFNGLTEXSTORAGE2DPROC pGlTexStorage2D;
|
||||
PFNGLTEXTURESTORAGE3DEXTPROC pGlTextureStorage3DEXT;
|
||||
PFNGLTEXSTORAGE3DPROC pGlTexStorage3D;
|
||||
PFNGLTEXTURESUBIMAGE2DEXTPROC pGlTextureSubImage2DEXT;
|
||||
PFNGLGETTEXTUREIMAGEEXTPROC pGlGetTextureImageEXT;
|
||||
PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC pGlNamedFramebufferTextureEXT;
|
||||
PFNGLFRAMEBUFFERTEXTUREPROC pGlFramebufferTexture;
|
||||
PFNGLGENERATETEXTUREMIPMAPEXTPROC pGlGenerateTextureMipmapEXT;
|
||||
@ -1938,6 +1955,36 @@ inline void COpenGLExtensionHandler::extGlUniformMatrix2fv(GLint loc, GLsizei co
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlUniformMatrix2x3fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat* v)
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
if (pGlUniformMatrix2x3fv)
|
||||
pGlUniformMatrix2x3fv(loc, count, transpose, v);
|
||||
else
|
||||
os::Printer::log("glUniformMatrix2x3fv not supported", ELL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlUniformMatrix2x4fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat* v)
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
if (pGlUniformMatrix2x4fv)
|
||||
pGlUniformMatrix2x4fv(loc, count, transpose, v);
|
||||
else
|
||||
os::Printer::log("glUniformMatrix2x4fv not supported", ELL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlUniformMatrix3x2fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat* v)
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
if (pGlUniformMatrix3x2fv)
|
||||
pGlUniformMatrix3x2fv(loc, count, transpose, v);
|
||||
else
|
||||
os::Printer::log("glUniformMatrix3x2fv not supported", ELL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlUniformMatrix3fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v)
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
@ -1950,6 +1997,36 @@ inline void COpenGLExtensionHandler::extGlUniformMatrix3fv(GLint loc, GLsizei co
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlUniformMatrix3x4fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat* v)
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
if (pGlUniformMatrix3x4fv)
|
||||
pGlUniformMatrix3x4fv(loc, count, transpose, v);
|
||||
else
|
||||
os::Printer::log("glUniformMatrix3x4fv not supported", ELL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlUniformMatrix4x2fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat* v)
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
if (pGlUniformMatrix4x2fv)
|
||||
pGlUniformMatrix4x2fv(loc, count, transpose, v);
|
||||
else
|
||||
os::Printer::log("glUniformMatrix4x2fv not supported", ELL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlUniformMatrix4x3fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat* v)
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
if (pGlUniformMatrix4x3fv)
|
||||
pGlUniformMatrix4x3fv(loc, count, transpose, v);
|
||||
else
|
||||
os::Printer::log("glUniformMatrix4x3fv not supported", ELL_ERROR);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlUniformMatrix4fv(GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v)
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
@ -2730,7 +2807,7 @@ inline void COpenGLExtensionHandler::irrGlBlendEquationSeparateIndexed(GLuint bu
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlTextureSubImage2D(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
|
||||
{
|
||||
if (Version>=450)
|
||||
if (Version>=405 || FeatureAvailable[IRR_ARB_direct_state_access])
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
if (pGlTextureSubImage2D)
|
||||
@ -2784,7 +2861,7 @@ inline void COpenGLExtensionHandler::extGlTextureSubImage2D(GLuint texture, GLen
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlTextureStorage2D(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
|
||||
{
|
||||
if (Version>=450)
|
||||
if (Version>=405 || FeatureAvailable[IRR_ARB_direct_state_access])
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
if (pGlTextureStorage2D)
|
||||
@ -2838,7 +2915,7 @@ inline void COpenGLExtensionHandler::extGlTextureStorage2D(GLuint texture, GLenu
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlTextureStorage3D(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
|
||||
{
|
||||
if (Version>=450)
|
||||
if (Version>=405 || FeatureAvailable[IRR_ARB_direct_state_access])
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
if (pGlTextureStorage3D)
|
||||
@ -2887,11 +2964,54 @@ inline void COpenGLExtensionHandler::extGlTextureStorage3D(GLuint texture, GLenu
|
||||
}
|
||||
}
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlGetTextureImage(GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void* pixels)
|
||||
{
|
||||
if (Version>=405 || FeatureAvailable[IRR_ARB_direct_state_access])
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
if (pGlGetTextureImage)
|
||||
pGlGetTextureImage(texture,level,format,type,bufSize,pixels);
|
||||
#else
|
||||
glGetTextureImage(texture,level,format,type,bufSize,pixels);
|
||||
#endif // _IRR_OPENGL_USE_EXTPOINTER_
|
||||
}
|
||||
else if (FeatureAvailable[IRR_EXT_direct_state_access])
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
if (pGlGetTextureImageEXT)
|
||||
pGlGetTextureImageEXT(texture,target,level,format,type,pixels);
|
||||
#else
|
||||
glGetTextureImageEXT(texture,target,level,format,type,pixels);
|
||||
#endif // _IRR_OPENGL_USE_EXTPOINTER_
|
||||
}
|
||||
else
|
||||
{
|
||||
GLint bound;
|
||||
switch (target)
|
||||
{
|
||||
case GL_TEXTURE_2D_ARRAY:
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D_ARRAY, &bound);
|
||||
break;
|
||||
case GL_TEXTURE_3D:
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_3D, &bound);
|
||||
break;
|
||||
case GL_TEXTURE_CUBE_MAP_ARRAY:
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARRAY, &bound);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
glBindTexture(target, texture);
|
||||
glGetTexImage(target,level,format,type,pixels);
|
||||
glBindTexture(target, bound);
|
||||
}
|
||||
}
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlNamedFramebufferTexture(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level)
|
||||
{
|
||||
if (!needsDSAFramebufferHack)
|
||||
{
|
||||
if (Version>=450)
|
||||
if (Version>=405 || FeatureAvailable[IRR_ARB_direct_state_access])
|
||||
{
|
||||
pGlNamedFramebufferTexture(framebuffer, attachment, texture, level);
|
||||
return;
|
||||
@ -2925,7 +3045,7 @@ inline void COpenGLExtensionHandler::extGlTextureParameteri(GLuint texture, GLen
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlCreateTextures(GLenum target, GLsizei n, GLuint* textures)
|
||||
{
|
||||
if (Version>=450)
|
||||
if (Version>=405)
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
if (pGlCreateTextures)
|
||||
@ -2946,7 +3066,7 @@ inline void COpenGLExtensionHandler::extGlCreateFramebuffers(GLsizei n, GLuint*
|
||||
{
|
||||
if (!needsDSAFramebufferHack)
|
||||
{
|
||||
if (Version>=450)
|
||||
if (Version>=405)
|
||||
{
|
||||
pGlCreateFramebuffers(n, framebuffers);
|
||||
return;
|
||||
@ -2963,7 +3083,7 @@ inline void COpenGLExtensionHandler::extGlBindTextures(GLuint first, GLsizei cou
|
||||
GL_TEXTURE_1D_ARRAY,GL_TEXTURE_2D_ARRAY,GL_TEXTURE_BUFFER, // GL 3.x
|
||||
GL_TEXTURE_CUBE_MAP_ARRAY,GL_TEXTURE_2D_MULTISAMPLE,GL_TEXTURE_2D_MULTISAMPLE_ARRAY}; // GL 4.x
|
||||
|
||||
if (Version>=440||FeatureAvailable[IRR_ARB_multi_bind])
|
||||
if (Version>=404||FeatureAvailable[IRR_ARB_multi_bind])
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
if (pGlBindTextures)
|
||||
@ -2999,7 +3119,7 @@ inline void COpenGLExtensionHandler::extGlBindTextures(GLuint first, GLsizei cou
|
||||
|
||||
inline void COpenGLExtensionHandler::extGlGenerateTextureMipmap(GLuint texture, GLenum target)
|
||||
{
|
||||
if (Version>=450)
|
||||
if (Version>=405 || FeatureAvailable[IRR_ARB_direct_state_access])
|
||||
{
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
if (pGlGenerateTextureMipmap)
|
||||
|
@ -633,9 +633,27 @@ bool COpenGLSLMaterialRenderer::setPixelShaderConstant(s32 index, const f32* flo
|
||||
case GL_FLOAT_MAT2:
|
||||
Driver->extGlUniformMatrix2fv(UniformInfo[index].location, count/4, false, floats);
|
||||
break;
|
||||
case GL_FLOAT_MAT2x3:
|
||||
Driver->extGlUniformMatrix2x3fv(UniformInfo[index].location, count/6, false, floats);
|
||||
break;
|
||||
case GL_FLOAT_MAT2x4:
|
||||
Driver->extGlUniformMatrix2x4fv(UniformInfo[index].location, count/8, false, floats);
|
||||
break;
|
||||
case GL_FLOAT_MAT3x2:
|
||||
Driver->extGlUniformMatrix3x2fv(UniformInfo[index].location, count/6, false, floats);
|
||||
break;
|
||||
case GL_FLOAT_MAT3:
|
||||
Driver->extGlUniformMatrix3fv(UniformInfo[index].location, count/9, false, floats);
|
||||
break;
|
||||
case GL_FLOAT_MAT3x4:
|
||||
Driver->extGlUniformMatrix3x4fv(UniformInfo[index].location, count/12, false, floats);
|
||||
break;
|
||||
case GL_FLOAT_MAT4x2:
|
||||
Driver->extGlUniformMatrix4x2fv(UniformInfo[index].location, count/8, false, floats);
|
||||
break;
|
||||
case GL_FLOAT_MAT4x3:
|
||||
Driver->extGlUniformMatrix4x3fv(UniformInfo[index].location, count/12, false, floats);
|
||||
break;
|
||||
case GL_FLOAT_MAT4:
|
||||
Driver->extGlUniformMatrix4fv(UniformInfo[index].location, count/16, false, floats);
|
||||
break;
|
||||
@ -648,7 +666,7 @@ bool COpenGLSLMaterialRenderer::setPixelShaderConstant(s32 index, const f32* flo
|
||||
{
|
||||
if(floats)
|
||||
{
|
||||
const GLint id = static_cast<const GLint>(*floats);
|
||||
const GLint id = static_cast<GLint>(*floats);
|
||||
Driver->extGlUniform1iv(UniformInfo[index].location, 1, &id);
|
||||
}
|
||||
else
|
||||
|
@ -230,7 +230,7 @@ IAnimatedMesh* CPLYMeshFileLoader::createMesh(io::IReadFile* file)
|
||||
if (continueReading)
|
||||
{
|
||||
// create a mesh buffer
|
||||
CDynamicMeshBuffer *mb = new CDynamicMeshBuffer(video::EVT_STANDARD, vertCount > 65565 ? video::EIT_32BIT : video::EIT_16BIT);
|
||||
CDynamicMeshBuffer *mb = new CDynamicMeshBuffer(video::EVT_STANDARD, vertCount > 65536 ? video::EIT_32BIT : video::EIT_16BIT);
|
||||
mb->getVertexBuffer().reallocate(vertCount);
|
||||
mb->getIndexBuffer().reallocate(vertCount);
|
||||
mb->setHardwareMappingHint(EHM_STATIC);
|
||||
|
@ -109,7 +109,7 @@ aes_rval aes_encrypt(const void *in_blk, void *out_blk, const aes_encrypt_ctx cx
|
||||
aes_32t nr = (kp[45] ^ kp[52] ^ kp[53] ? kp[52] : 14);
|
||||
|
||||
#ifdef AES_ERR_CHK
|
||||
if( (nr != 10 || !(kp[0] | kp[3] | kp[4]))
|
||||
if( (nr != 10 || !(kp[0] | kp[3] | kp[4]))
|
||||
&& (nr != 12 || !(kp[0] | kp[5] | kp[6]))
|
||||
&& (nr != 14 || !(kp[0] | kp[7] | kp[8])) )
|
||||
return aes_error;
|
||||
@ -125,10 +125,12 @@ aes_rval aes_encrypt(const void *in_blk, void *out_blk, const aes_encrypt_ctx cx
|
||||
round(fwd_rnd, b1, b0, kp + 1 * N_COLS);
|
||||
round(fwd_rnd, b0, b1, kp + 2 * N_COLS);
|
||||
kp += 2 * N_COLS;
|
||||
/* Falls through. */
|
||||
case 12:
|
||||
round(fwd_rnd, b1, b0, kp + 1 * N_COLS);
|
||||
round(fwd_rnd, b0, b1, kp + 2 * N_COLS);
|
||||
kp += 2 * N_COLS;
|
||||
/* Falls through. */
|
||||
case 10:
|
||||
round(fwd_rnd, b1, b0, kp + 1 * N_COLS);
|
||||
round(fwd_rnd, b0, b1, kp + 2 * N_COLS);
|
||||
@ -233,7 +235,7 @@ aes_rval aes_decrypt(const void *in_blk, void *out_blk, const aes_decrypt_ctx cx
|
||||
const aes_32t *kp = cx->ks + nr * N_COLS;
|
||||
|
||||
#ifdef AES_ERR_CHK
|
||||
if( (nr != 10 || !(cx->ks[0] | cx->ks[3] | cx->ks[4]))
|
||||
if( (nr != 10 || !(cx->ks[0] | cx->ks[3] | cx->ks[4]))
|
||||
&& (nr != 12 || !(cx->ks[0] | cx->ks[5] | cx->ks[6]))
|
||||
&& (nr != 14 || !(cx->ks[0] | cx->ks[7] | cx->ks[8])) )
|
||||
return aes_error;
|
||||
@ -249,10 +251,12 @@ aes_rval aes_decrypt(const void *in_blk, void *out_blk, const aes_decrypt_ctx cx
|
||||
round(inv_rnd, b1, b0, kp - 1 * N_COLS);
|
||||
round(inv_rnd, b0, b1, kp - 2 * N_COLS);
|
||||
kp -= 2 * N_COLS;
|
||||
/* Falls through. */
|
||||
case 12:
|
||||
round(inv_rnd, b1, b0, kp - 1 * N_COLS);
|
||||
round(inv_rnd, b0, b1, kp - 2 * N_COLS);
|
||||
kp -= 2 * N_COLS;
|
||||
/* Falls through. */
|
||||
case 10:
|
||||
round(inv_rnd, b1, b0, kp - 1 * N_COLS);
|
||||
round(inv_rnd, b0, b1, kp - 2 * N_COLS);
|
||||
|
@ -5,60 +5,60 @@
|
||||
|
||||
LICENSE TERMS
|
||||
|
||||
The free distribution and use of this software in both source and binary
|
||||
The free distribution and use of this software in both source and binary
|
||||
form is allowed (with or without changes) provided that:
|
||||
|
||||
1. distributions of this source code include the above copyright
|
||||
1. distributions of this source code include the above copyright
|
||||
notice, this list of conditions and the following disclaimer;
|
||||
|
||||
2. distributions in binary form include the above copyright
|
||||
notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other associated materials;
|
||||
|
||||
3. the copyright holder's name is not used to endorse products
|
||||
built using this software without specific written permission.
|
||||
3. the copyright holder's name is not used to endorse products
|
||||
built using this software without specific written permission.
|
||||
|
||||
ALTERNATIVELY, provided that this notice is retained in full, this product
|
||||
may be distributed under the terms of the GNU General Public License (GPL),
|
||||
in which case the provisions of the GPL apply INSTEAD OF those given above.
|
||||
|
||||
|
||||
DISCLAIMER
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its properties, including, but not limited to, correctness
|
||||
in respect of its properties, including, but not limited to, correctness
|
||||
and/or fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue Date: 26/08/2003
|
||||
|
||||
This is a byte oriented version of SHA2 that operates on arrays of bytes
|
||||
stored in memory. This code implements sha256, sha384 and sha512 but the
|
||||
latter two functions rely on efficient 64-bit integer operations that
|
||||
latter two functions rely on efficient 64-bit integer operations that
|
||||
may not be very efficient on 32-bit machines
|
||||
|
||||
The sha256 functions use a type 'sha256_ctx' to hold details of the
|
||||
The sha256 functions use a type 'sha256_ctx' to hold details of the
|
||||
current hash state and uses the following three calls:
|
||||
|
||||
void sha256_begin(sha256_ctx ctx[1])
|
||||
void sha256_hash(const unsigned char data[],
|
||||
void sha256_hash(const unsigned char data[],
|
||||
unsigned long len, sha256_ctx ctx[1])
|
||||
void sha256_end(unsigned char hval[], sha256_ctx ctx[1])
|
||||
|
||||
The first subroutine initialises a hash computation by setting up the
|
||||
context in the sha256_ctx context. The second subroutine hashes 8-bit
|
||||
bytes from array data[] into the hash state withinh sha256_ctx context,
|
||||
the number of bytes to be hashed being given by the the unsigned long
|
||||
integer len. The third subroutine completes the hash calculation and
|
||||
The first subroutine initialises a hash computation by setting up the
|
||||
context in the sha256_ctx context. The second subroutine hashes 8-bit
|
||||
bytes from array data[] into the hash state withinh sha256_ctx context,
|
||||
the number of bytes to be hashed being given by the the unsigned long
|
||||
integer len. The third subroutine completes the hash calculation and
|
||||
places the resulting digest value in the array of 8-bit bytes hval[].
|
||||
|
||||
The sha384 and sha512 functions are similar and use the interfaces:
|
||||
|
||||
void sha384_begin(sha384_ctx ctx[1]);
|
||||
void sha384_hash(const unsigned char data[],
|
||||
void sha384_hash(const unsigned char data[],
|
||||
unsigned long len, sha384_ctx ctx[1]);
|
||||
void sha384_end(unsigned char hval[], sha384_ctx ctx[1]);
|
||||
|
||||
void sha512_begin(sha512_ctx ctx[1]);
|
||||
void sha512_hash(const unsigned char data[],
|
||||
void sha512_hash(const unsigned char data[],
|
||||
unsigned long len, sha512_ctx ctx[1]);
|
||||
void sha512_end(unsigned char hval[], sha512_ctx ctx[1]);
|
||||
|
||||
@ -66,11 +66,11 @@
|
||||
functions using a call with a hash length parameter as follows:
|
||||
|
||||
int sha2_begin(unsigned long len, sha2_ctx ctx[1]);
|
||||
void sha2_hash(const unsigned char data[],
|
||||
void sha2_hash(const unsigned char data[],
|
||||
unsigned long len, sha2_ctx ctx[1]);
|
||||
void sha2_end(unsigned char hval[], sha2_ctx ctx[1]);
|
||||
|
||||
My thanks to Erik Andersen <andersen@codepoet.org> for testing this code
|
||||
My thanks to Erik Andersen <andersen@codepoet.org> for testing this code
|
||||
on big-endian systems and for his assistance with corrections
|
||||
*/
|
||||
|
||||
@ -90,11 +90,11 @@
|
||||
/* BYTE ORDER IN 32-BIT WORDS
|
||||
|
||||
To obtain the highest speed on processors with 32-bit words, this code
|
||||
needs to determine the byte order of the target machine. The following
|
||||
block of code is an attempt to capture the most obvious ways in which
|
||||
various environemnts define byte order. It may well fail, in which case
|
||||
the definitions will need to be set by editing at the points marked
|
||||
**** EDIT HERE IF NECESSARY **** below. My thanks to Peter Gutmann for
|
||||
needs to determine the byte order of the target machine. The following
|
||||
block of code is an attempt to capture the most obvious ways in which
|
||||
various environemnts define byte order. It may well fail, in which case
|
||||
the definitions will need to be set by editing at the points marked
|
||||
**** EDIT HERE IF NECESSARY **** below. My thanks to Peter Gutmann for
|
||||
some of these defines (from cryptlib).
|
||||
*/
|
||||
|
||||
@ -130,7 +130,7 @@
|
||||
#if defined(SWAP_BYTES)
|
||||
#define bsw_32(p,n) { int _i = (n); while(_i--) p[_i] = bswap_32(p[_i]); }
|
||||
#else
|
||||
#define bsw_32(p,n)
|
||||
#define bsw_32(p,n)
|
||||
#endif
|
||||
|
||||
/* SHA256 mixing function definitions */
|
||||
@ -147,10 +147,10 @@
|
||||
|
||||
#endif
|
||||
|
||||
#define s256_0(x) (rotr32((x), 2) ^ rotr32((x), 13) ^ rotr32((x), 22))
|
||||
#define s256_1(x) (rotr32((x), 6) ^ rotr32((x), 11) ^ rotr32((x), 25))
|
||||
#define g256_0(x) (rotr32((x), 7) ^ rotr32((x), 18) ^ ((x) >> 3))
|
||||
#define g256_1(x) (rotr32((x), 17) ^ rotr32((x), 19) ^ ((x) >> 10))
|
||||
#define s256_0(x) (rotr32((x), 2) ^ rotr32((x), 13) ^ rotr32((x), 22))
|
||||
#define s256_1(x) (rotr32((x), 6) ^ rotr32((x), 11) ^ rotr32((x), 25))
|
||||
#define g256_0(x) (rotr32((x), 7) ^ rotr32((x), 18) ^ ((x) >> 3))
|
||||
#define g256_1(x) (rotr32((x), 17) ^ rotr32((x), 19) ^ ((x) >> 10))
|
||||
|
||||
/* rotated SHA256 round definition. Rather than swapping variables as in */
|
||||
/* FIPS-180, different variables are 'rotated' on each round, returning */
|
||||
@ -168,21 +168,21 @@
|
||||
/* SHA256 mixing data */
|
||||
|
||||
const sha2_32t k256[64] =
|
||||
{ n_u32(428a2f98), n_u32(71374491), n_u32(b5c0fbcf), n_u32(e9b5dba5),
|
||||
n_u32(3956c25b), n_u32(59f111f1), n_u32(923f82a4), n_u32(ab1c5ed5),
|
||||
n_u32(d807aa98), n_u32(12835b01), n_u32(243185be), n_u32(550c7dc3),
|
||||
n_u32(72be5d74), n_u32(80deb1fe), n_u32(9bdc06a7), n_u32(c19bf174),
|
||||
n_u32(e49b69c1), n_u32(efbe4786), n_u32(0fc19dc6), n_u32(240ca1cc),
|
||||
n_u32(2de92c6f), n_u32(4a7484aa), n_u32(5cb0a9dc), n_u32(76f988da),
|
||||
n_u32(983e5152), n_u32(a831c66d), n_u32(b00327c8), n_u32(bf597fc7),
|
||||
n_u32(c6e00bf3), n_u32(d5a79147), n_u32(06ca6351), n_u32(14292967),
|
||||
n_u32(27b70a85), n_u32(2e1b2138), n_u32(4d2c6dfc), n_u32(53380d13),
|
||||
{ n_u32(428a2f98), n_u32(71374491), n_u32(b5c0fbcf), n_u32(e9b5dba5),
|
||||
n_u32(3956c25b), n_u32(59f111f1), n_u32(923f82a4), n_u32(ab1c5ed5),
|
||||
n_u32(d807aa98), n_u32(12835b01), n_u32(243185be), n_u32(550c7dc3),
|
||||
n_u32(72be5d74), n_u32(80deb1fe), n_u32(9bdc06a7), n_u32(c19bf174),
|
||||
n_u32(e49b69c1), n_u32(efbe4786), n_u32(0fc19dc6), n_u32(240ca1cc),
|
||||
n_u32(2de92c6f), n_u32(4a7484aa), n_u32(5cb0a9dc), n_u32(76f988da),
|
||||
n_u32(983e5152), n_u32(a831c66d), n_u32(b00327c8), n_u32(bf597fc7),
|
||||
n_u32(c6e00bf3), n_u32(d5a79147), n_u32(06ca6351), n_u32(14292967),
|
||||
n_u32(27b70a85), n_u32(2e1b2138), n_u32(4d2c6dfc), n_u32(53380d13),
|
||||
n_u32(650a7354), n_u32(766a0abb), n_u32(81c2c92e), n_u32(92722c85),
|
||||
n_u32(a2bfe8a1), n_u32(a81a664b), n_u32(c24b8b70), n_u32(c76c51a3),
|
||||
n_u32(d192e819), n_u32(d6990624), n_u32(f40e3585), n_u32(106aa070),
|
||||
n_u32(19a4c116), n_u32(1e376c08), n_u32(2748774c), n_u32(34b0bcb5),
|
||||
n_u32(391c0cb3), n_u32(4ed8aa4a), n_u32(5b9cca4f), n_u32(682e6ff3),
|
||||
n_u32(748f82ee), n_u32(78a5636f), n_u32(84c87814), n_u32(8cc70208),
|
||||
n_u32(a2bfe8a1), n_u32(a81a664b), n_u32(c24b8b70), n_u32(c76c51a3),
|
||||
n_u32(d192e819), n_u32(d6990624), n_u32(f40e3585), n_u32(106aa070),
|
||||
n_u32(19a4c116), n_u32(1e376c08), n_u32(2748774c), n_u32(34b0bcb5),
|
||||
n_u32(391c0cb3), n_u32(4ed8aa4a), n_u32(5b9cca4f), n_u32(682e6ff3),
|
||||
n_u32(748f82ee), n_u32(78a5636f), n_u32(84c87814), n_u32(8cc70208),
|
||||
n_u32(90befffa), n_u32(a4506ceb), n_u32(bef9a3f7), n_u32(c67178f2),
|
||||
};
|
||||
|
||||
@ -228,7 +228,7 @@ sha2_void sha256_compile(sha256_ctx ctx[1])
|
||||
/* and call the hash_compile function as required. */
|
||||
|
||||
sha2_void sha256_hash(const unsigned char data[], unsigned long len, sha256_ctx ctx[1])
|
||||
{ sha2_32t pos = (sha2_32t)(ctx->count[0] & SHA256_MASK),
|
||||
{ sha2_32t pos = (sha2_32t)(ctx->count[0] & SHA256_MASK),
|
||||
space = SHA256_BLOCK_SIZE - pos;
|
||||
const unsigned char *sp = data;
|
||||
|
||||
@ -238,7 +238,7 @@ sha2_void sha256_hash(const unsigned char data[], unsigned long len, sha256_ctx
|
||||
while(len >= space) /* tranfer whole blocks while possible */
|
||||
{
|
||||
memcpy(((unsigned char*)ctx->wbuf) + pos, sp, space);
|
||||
sp += space; len -= space; space = SHA256_BLOCK_SIZE; pos = 0;
|
||||
sp += space; len -= space; space = SHA256_BLOCK_SIZE; pos = 0;
|
||||
bsw_32(ctx->wbuf, SHA256_BLOCK_SIZE >> 2)
|
||||
sha256_compile(ctx);
|
||||
}
|
||||
@ -265,7 +265,7 @@ sha2_void sha256_end(unsigned char hval[], sha256_ctx ctx[1])
|
||||
/* bytes in the buffer are now in an order in which references */
|
||||
/* to 32-bit words will put bytes with lower addresses into the */
|
||||
/* top of 32 bit words on BOTH big and little endian machines */
|
||||
|
||||
|
||||
/* we now need to mask valid bytes and add the padding which is */
|
||||
/* a single 1 bit and as many zero bits as necessary. */
|
||||
ctx->wbuf[i >> 2] = (ctx->wbuf[i >> 2] & m1[i & 3]) | b1[i & 3];
|
||||
@ -282,9 +282,9 @@ sha2_void sha256_end(unsigned char hval[], sha256_ctx ctx[1])
|
||||
else /* compute a word index for the empty buffer positions */
|
||||
i = (i >> 2) + 1;
|
||||
|
||||
while(i < 14) /* and zero pad all but last two positions */
|
||||
while(i < 14) /* and zero pad all but last two positions */
|
||||
ctx->wbuf[i++] = 0;
|
||||
|
||||
|
||||
/* the following 32-bit length fields are assembled in the */
|
||||
/* wrong byte order on little endian machines but this is */
|
||||
/* corrected later since they are only ever used as 32-bit */
|
||||
@ -301,9 +301,9 @@ sha2_void sha256_end(unsigned char hval[], sha256_ctx ctx[1])
|
||||
hval[i] = (unsigned char)(ctx->hash[i >> 2] >> (8 * (~i & 3)));
|
||||
}
|
||||
|
||||
sha2_void sha256(unsigned char hval[], const unsigned char data[], unsigned long len)
|
||||
sha2_void sha256(unsigned char hval[], const unsigned char data[], unsigned long len)
|
||||
{ sha256_ctx cx[1];
|
||||
|
||||
|
||||
sha256_begin(cx); sha256_hash(data, len, cx); sha256_end(hval, cx);
|
||||
}
|
||||
|
||||
@ -322,15 +322,15 @@ sha2_void sha256(unsigned char hval[], const unsigned char data[], unsigned long
|
||||
#if defined(SWAP_BYTES)
|
||||
#define bsw_64(p,n) { int _i = (n); while(_i--) p[_i] = bswap_64(p[_i]); }
|
||||
#else
|
||||
#define bsw_64(p,n)
|
||||
#define bsw_64(p,n)
|
||||
#endif
|
||||
|
||||
/* SHA512 mixing function definitions */
|
||||
|
||||
#define s512_0(x) (rotr64((x), 28) ^ rotr64((x), 34) ^ rotr64((x), 39))
|
||||
#define s512_1(x) (rotr64((x), 14) ^ rotr64((x), 18) ^ rotr64((x), 41))
|
||||
#define g512_0(x) (rotr64((x), 1) ^ rotr64((x), 8) ^ ((x) >> 7))
|
||||
#define g512_1(x) (rotr64((x), 19) ^ rotr64((x), 61) ^ ((x) >> 6))
|
||||
#define s512_0(x) (rotr64((x), 28) ^ rotr64((x), 34) ^ rotr64((x), 39))
|
||||
#define s512_1(x) (rotr64((x), 14) ^ rotr64((x), 18) ^ rotr64((x), 41))
|
||||
#define g512_0(x) (rotr64((x), 1) ^ rotr64((x), 8) ^ ((x) >> 7))
|
||||
#define g512_1(x) (rotr64((x), 19) ^ rotr64((x), 61) ^ ((x) >> 6))
|
||||
|
||||
/* rotated SHA512 round definition. Rather than swapping variables as in */
|
||||
/* FIPS-180, different variables are 'rotated' on each round, returning */
|
||||
@ -347,9 +347,9 @@ sha2_void sha256(unsigned char hval[], const unsigned char data[], unsigned long
|
||||
|
||||
/* SHA384/SHA512 mixing data */
|
||||
|
||||
const sha2_64t k512[80] =
|
||||
const sha2_64t k512[80] =
|
||||
{
|
||||
n_u64(428a2f98d728ae22), n_u64(7137449123ef65cd),
|
||||
n_u64(428a2f98d728ae22), n_u64(7137449123ef65cd),
|
||||
n_u64(b5c0fbcfec4d3b2f), n_u64(e9b5dba58189dbbc),
|
||||
n_u64(3956c25bf348b538), n_u64(59f111f1b605d019),
|
||||
n_u64(923f82a4af194f9b), n_u64(ab1c5ed5da6d8118),
|
||||
@ -419,7 +419,7 @@ sha2_void sha512_compile(sha512_ctx ctx[1])
|
||||
/* and little endian systems */
|
||||
|
||||
sha2_void sha512_hash(const unsigned char data[], unsigned long len, sha512_ctx ctx[1])
|
||||
{ sha2_32t pos = (sha2_32t)(ctx->count[0] & SHA512_MASK),
|
||||
{ sha2_32t pos = (sha2_32t)(ctx->count[0] & SHA512_MASK),
|
||||
space = SHA512_BLOCK_SIZE - pos;
|
||||
const unsigned char *sp = data;
|
||||
|
||||
@ -429,8 +429,8 @@ sha2_void sha512_hash(const unsigned char data[], unsigned long len, sha512_ctx
|
||||
while(len >= space) /* tranfer whole blocks while possible */
|
||||
{
|
||||
memcpy(((unsigned char*)ctx->wbuf) + pos, sp, space);
|
||||
sp += space; len -= space; space = SHA512_BLOCK_SIZE; pos = 0;
|
||||
bsw_64(ctx->wbuf, SHA512_BLOCK_SIZE >> 3);
|
||||
sp += space; len -= space; space = SHA512_BLOCK_SIZE; pos = 0;
|
||||
bsw_64(ctx->wbuf, SHA512_BLOCK_SIZE >> 3);
|
||||
sha512_compile(ctx);
|
||||
}
|
||||
|
||||
@ -441,7 +441,7 @@ sha2_void sha512_hash(const unsigned char data[], unsigned long len, sha512_ctx
|
||||
|
||||
static sha2_64t m2[8] =
|
||||
{
|
||||
n_u64(0000000000000000), n_u64(ff00000000000000),
|
||||
n_u64(0000000000000000), n_u64(ff00000000000000),
|
||||
n_u64(ffff000000000000), n_u64(ffffff0000000000),
|
||||
n_u64(ffffffff00000000), n_u64(ffffffffff000000),
|
||||
n_u64(ffffffffffff0000), n_u64(ffffffffffffff00)
|
||||
@ -449,9 +449,9 @@ static sha2_64t m2[8] =
|
||||
|
||||
static sha2_64t b2[8] =
|
||||
{
|
||||
n_u64(8000000000000000), n_u64(0080000000000000),
|
||||
n_u64(8000000000000000), n_u64(0080000000000000),
|
||||
n_u64(0000800000000000), n_u64(0000008000000000),
|
||||
n_u64(0000000080000000), n_u64(0000000000800000),
|
||||
n_u64(0000000080000000), n_u64(0000000000800000),
|
||||
n_u64(0000000000008000), n_u64(0000000000000080)
|
||||
};
|
||||
|
||||
@ -463,7 +463,7 @@ static void sha_end(unsigned char hval[], sha512_ctx ctx[1], const unsigned int
|
||||
/* bytes in the buffer are now in an order in which references */
|
||||
/* to 64-bit words will put bytes with lower addresses into the */
|
||||
/* top of 64 bit words on BOTH big and little endian machines */
|
||||
|
||||
|
||||
/* we now need to mask valid bytes and add the padding which is */
|
||||
/* a single 1 bit and as many zero bits as necessary. */
|
||||
ctx->wbuf[i >> 3] = (ctx->wbuf[i >> 3] & m2[i & 7]) | b2[i & 7];
|
||||
@ -482,7 +482,7 @@ static void sha_end(unsigned char hval[], sha512_ctx ctx[1], const unsigned int
|
||||
|
||||
while(i < 14)
|
||||
ctx->wbuf[i++] = 0;
|
||||
|
||||
|
||||
/* the following 64-bit length fields are assembled in the */
|
||||
/* wrong byte order on little endian machines but this is */
|
||||
/* corrected later since they are only ever used as 64-bit */
|
||||
@ -505,7 +505,7 @@ static void sha_end(unsigned char hval[], sha512_ctx ctx[1], const unsigned int
|
||||
|
||||
/* SHA384 initialisation data */
|
||||
|
||||
const sha2_64t i384[80] =
|
||||
const sha2_64t i384[80] =
|
||||
{
|
||||
n_u64(cbbb9d5dc1059ed8), n_u64(629a292a367cd507),
|
||||
n_u64(9159015a3070dd17), n_u64(152fecd8f70e5939),
|
||||
@ -526,7 +526,7 @@ sha2_void sha384_end(unsigned char hval[], sha384_ctx ctx[1])
|
||||
|
||||
sha2_void sha384(unsigned char hval[], const unsigned char data[], unsigned long len)
|
||||
{ sha384_ctx cx[1];
|
||||
|
||||
|
||||
sha384_begin(cx); sha384_hash(data, len, cx); sha384_end(hval, cx);
|
||||
}
|
||||
|
||||
@ -536,7 +536,7 @@ sha2_void sha384(unsigned char hval[], const unsigned char data[], unsigned long
|
||||
|
||||
/* SHA512 initialisation data */
|
||||
|
||||
const sha2_64t i512[80] =
|
||||
const sha2_64t i512[80] =
|
||||
{
|
||||
n_u64(6a09e667f3bcc908), n_u64(bb67ae8584caa73b),
|
||||
n_u64(3c6ef372fe94f82b), n_u64(a54ff53a5f1d36f1),
|
||||
@ -555,9 +555,9 @@ sha2_void sha512_end(unsigned char hval[], sha512_ctx ctx[1])
|
||||
sha_end(hval, ctx, SHA512_DIGEST_SIZE);
|
||||
}
|
||||
|
||||
sha2_void sha512(unsigned char hval[], const unsigned char data[], unsigned long len)
|
||||
sha2_void sha512(unsigned char hval[], const unsigned char data[], unsigned long len)
|
||||
{ sha512_ctx cx[1];
|
||||
|
||||
|
||||
sha512_begin(cx); sha512_hash(data, len, cx); sha512_end(hval, cx);
|
||||
}
|
||||
|
||||
@ -576,17 +576,20 @@ sha2_int sha2_begin(unsigned long len, sha2_ctx ctx[1])
|
||||
switch(len)
|
||||
{
|
||||
case 256: l = len >> 3;
|
||||
/* Falls through. */
|
||||
case 32: CTX_256(ctx)->count[0] = CTX_256(ctx)->count[1] = 0;
|
||||
memcpy(CTX_256(ctx)->hash, i256, 32); break;
|
||||
case 384: l = len >> 3;
|
||||
/* Falls through. */
|
||||
case 48: CTX_384(ctx)->count[0] = CTX_384(ctx)->count[1] = 0;
|
||||
memcpy(CTX_384(ctx)->hash, i384, 64); break;
|
||||
case 512: l = len >> 3;
|
||||
/* Falls through. */
|
||||
case 64: CTX_512(ctx)->count[0] = CTX_512(ctx)->count[1] = 0;
|
||||
memcpy(CTX_512(ctx)->hash, i512, 64); break;
|
||||
default: return SHA2_BAD;
|
||||
}
|
||||
|
||||
|
||||
ctx->sha2_len = l; return SHA2_GOOD;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user