mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-29 07:22:07 +00:00
- reinstated the far superior assembly HQnX version for Visual C++.
This commit is contained in:
parent
86d37e06f9
commit
6f65bccf1c
8 changed files with 13761 additions and 4 deletions
|
@ -581,6 +581,10 @@ endif( NOT DYN_FLUIDSYNTH )
|
||||||
|
|
||||||
# Start defining source files for ZDoom
|
# Start defining source files for ZDoom
|
||||||
set( PLAT_WIN32_SOURCES
|
set( PLAT_WIN32_SOURCES
|
||||||
|
gl/hqnx_asm/hq2x_asm.cpp
|
||||||
|
gl/hqnx_asm/hq3x_asm.cpp
|
||||||
|
gl/hqnx_asm/hq4x_asm.cpp
|
||||||
|
gl/hqnx_asm/hqnx_asm_Image.cpp
|
||||||
win32/eaxedit.cpp
|
win32/eaxedit.cpp
|
||||||
win32/fb_d3d9.cpp
|
win32/fb_d3d9.cpp
|
||||||
win32/fb_d3d9_wipe.cpp
|
win32/fb_d3d9_wipe.cpp
|
||||||
|
@ -727,6 +731,7 @@ file( GLOB HEADER_FILES
|
||||||
gl/data/*.h
|
gl/data/*.h
|
||||||
gl/dynlights/*.h
|
gl/dynlights/*.h
|
||||||
gl/hqnx/*.h
|
gl/hqnx/*.h
|
||||||
|
gl/hqnx_asm/*.h
|
||||||
gl/models/*.h
|
gl/models/*.h
|
||||||
gl/renderer/*.h
|
gl/renderer/*.h
|
||||||
gl/scene/*.h
|
gl/scene/*.h
|
||||||
|
@ -1298,6 +1303,7 @@ source_group("OpenGL Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/
|
||||||
source_group("OpenGL Renderer\\Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/data/.+")
|
source_group("OpenGL Renderer\\Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/data/.+")
|
||||||
source_group("OpenGL Renderer\\Dynamic Lights" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/dynlights/.+")
|
source_group("OpenGL Renderer\\Dynamic Lights" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/dynlights/.+")
|
||||||
source_group("OpenGL Renderer\\HQ Resize" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/hqnx/.+")
|
source_group("OpenGL Renderer\\HQ Resize" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/hqnx/.+")
|
||||||
|
source_group("OpenGL Renderer\\HQ Resize Assembly version" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/hqnx_asm/.+")
|
||||||
source_group("OpenGL Renderer\\Models" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/models/.+")
|
source_group("OpenGL Renderer\\Models" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/models/.+")
|
||||||
source_group("OpenGL Renderer\\Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/renderer/.+")
|
source_group("OpenGL Renderer\\Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/renderer/.+")
|
||||||
source_group("OpenGL Renderer\\Scene" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/scene/.+")
|
source_group("OpenGL Renderer\\Scene" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/scene/.+")
|
||||||
|
|
2991
src/gl/hqnx_asm/hq2x_asm.cpp
Normal file
2991
src/gl/hqnx_asm/hq2x_asm.cpp
Normal file
File diff suppressed because it is too large
Load diff
3874
src/gl/hqnx_asm/hq3x_asm.cpp
Normal file
3874
src/gl/hqnx_asm/hq3x_asm.cpp
Normal file
File diff suppressed because it is too large
Load diff
5474
src/gl/hqnx_asm/hq4x_asm.cpp
Normal file
5474
src/gl/hqnx_asm/hq4x_asm.cpp
Normal file
File diff suppressed because it is too large
Load diff
39
src/gl/hqnx_asm/hqnx_asm.h
Normal file
39
src/gl/hqnx_asm/hqnx_asm.h
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
//hqnx filter library
|
||||||
|
//----------------------------------------------------------
|
||||||
|
//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com )
|
||||||
|
//Copyright (C) 2009 Benjamin Berkels
|
||||||
|
//
|
||||||
|
//This program is free software; you can redistribute it and/or
|
||||||
|
//modify it under the terms of the GNU Lesser General Public
|
||||||
|
//License as published by the Free Software Foundation; either
|
||||||
|
//version 2.1 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
//This program is distributed in the hope that it will be useful,
|
||||||
|
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
//Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
//You should have received a copy of the GNU Lesser General Public
|
||||||
|
//License along with this program; if not, write to the Free Software
|
||||||
|
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
#ifndef __HQNX_H__
|
||||||
|
#define __HQNX_H__
|
||||||
|
|
||||||
|
#pragma warning(disable:4799)
|
||||||
|
|
||||||
|
#include "hqnx_asm_Image.h"
|
||||||
|
|
||||||
|
namespace HQnX_asm
|
||||||
|
{
|
||||||
|
void DLL hq2x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL );
|
||||||
|
void DLL hq3x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL );
|
||||||
|
void DLL hq4x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL );
|
||||||
|
int DLL hq4x_32 ( CImage &ImageIn, CImage &ImageOut );
|
||||||
|
|
||||||
|
void DLL InitLUTs();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif //__HQNX_H__
|
1179
src/gl/hqnx_asm/hqnx_asm_Image.cpp
Normal file
1179
src/gl/hqnx_asm/hqnx_asm_Image.cpp
Normal file
File diff suppressed because it is too large
Load diff
150
src/gl/hqnx_asm/hqnx_asm_Image.h
Normal file
150
src/gl/hqnx_asm/hqnx_asm_Image.h
Normal file
|
@ -0,0 +1,150 @@
|
||||||
|
//CImage class - loading and saving BMP and TGA files
|
||||||
|
//----------------------------------------------------------
|
||||||
|
//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com )
|
||||||
|
//
|
||||||
|
//This program is free software; you can redistribute it and/or
|
||||||
|
//modify it under the terms of the GNU Lesser General Public
|
||||||
|
//License as published by the Free Software Foundation; either
|
||||||
|
//version 2.1 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
//This program is distributed in the hope that it will be useful,
|
||||||
|
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
//Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
//You should have received a copy of the GNU Lesser General Public
|
||||||
|
//License along with this program; if not, write to the Free Software
|
||||||
|
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
//#ifdef WIN32
|
||||||
|
//#define DLL __declspec(dllexport)
|
||||||
|
//#else
|
||||||
|
#define DLL
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#pragma once
|
||||||
|
#pragma warning(disable: 4103)
|
||||||
|
#pragma pack(1)
|
||||||
|
|
||||||
|
namespace HQnX_asm
|
||||||
|
{
|
||||||
|
|
||||||
|
typedef struct { unsigned char b, g, r; } _BGR;
|
||||||
|
typedef struct { unsigned char b, g, r, a; } _BGRA;
|
||||||
|
|
||||||
|
class CImage
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DLL CImage();
|
||||||
|
DLL ~CImage();
|
||||||
|
|
||||||
|
enum CImageErrors
|
||||||
|
{
|
||||||
|
eConvUnknownFormat = 10,
|
||||||
|
eConvSourceMemory = 11,
|
||||||
|
eConvDestMemory = 12,
|
||||||
|
|
||||||
|
eSaveBmpFileOpen = 20,
|
||||||
|
eSaveBmpFileWrite = 21,
|
||||||
|
eSaveBmpSourceMemory = 22,
|
||||||
|
eSaveBmpColorDepth = 23,
|
||||||
|
|
||||||
|
eLoadBmpFileOpen = 30,
|
||||||
|
eLoadBmpFileRead = 31,
|
||||||
|
eLoadBmpBadFormat = 32,
|
||||||
|
eLoadBmpInit = 33,
|
||||||
|
eLoadBmpColorDepth = 34,
|
||||||
|
|
||||||
|
eSaveTgaFileOpen = 40,
|
||||||
|
eSaveTgaFileWrite = 41,
|
||||||
|
eSaveTgaSourceMemory = 42,
|
||||||
|
eSaveTgaColorDepth = 43,
|
||||||
|
|
||||||
|
eLoadTgaFileOpen = 50,
|
||||||
|
eLoadTgaFileRead = 51,
|
||||||
|
eLoadTgaBadFormat = 52,
|
||||||
|
eLoadTgaInit = 53,
|
||||||
|
eLoadTgaColorDepth = 54,
|
||||||
|
|
||||||
|
eLoadFilename = 60,
|
||||||
|
eSaveFilename = 61,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _BMPFILEHEADER
|
||||||
|
{
|
||||||
|
unsigned short bfType;
|
||||||
|
long int bfSize, bfRes1, bfOffBits;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _BMPIMAGEHEADEROLD
|
||||||
|
{
|
||||||
|
long int biSize;
|
||||||
|
unsigned short biWidth, biHeight;
|
||||||
|
unsigned short biPlanes, biBitCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _BMPIMAGEHEADER
|
||||||
|
{
|
||||||
|
long int biSize, biWidth, biHeight;
|
||||||
|
unsigned short biPlanes, biBitCount;
|
||||||
|
long int biCompression, biSizeImage;
|
||||||
|
long int biXPelsPerMeter, biYPelsPerMeter;
|
||||||
|
long int biClrUsed, biClrImportant;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _TGAHEADER
|
||||||
|
{
|
||||||
|
unsigned char tiIdentSize;
|
||||||
|
unsigned char tiPaletteIncluded;
|
||||||
|
unsigned char tiImageType;
|
||||||
|
unsigned short tiPaletteStart;
|
||||||
|
unsigned short tiPaletteSize;
|
||||||
|
unsigned char tiPaletteBpp;
|
||||||
|
unsigned short tiX0;
|
||||||
|
unsigned short tiY0;
|
||||||
|
unsigned short tiXres;
|
||||||
|
unsigned short tiYres;
|
||||||
|
unsigned char tiBitPerPixel;
|
||||||
|
unsigned char tiAttrBits;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
int DLL Init( int Xres, int Yres, unsigned short BitPerPixel );
|
||||||
|
int DLL SetImage(unsigned char *img, int width, int height, int bpp);
|
||||||
|
int DLL Destroy();
|
||||||
|
int DLL ConvertTo32( void );
|
||||||
|
int DLL ConvertTo24( void );
|
||||||
|
int DLL ConvertTo16( void );
|
||||||
|
int DLL Convert8To17( int transindex );
|
||||||
|
int DLL Convert32To17( void );
|
||||||
|
int SaveBmp(char *szFilename);
|
||||||
|
int LoadBmp(char *szFilename);
|
||||||
|
int SaveTga(char *szFilename, bool bCompressed );
|
||||||
|
int LoadTga(char *szFilename);
|
||||||
|
int DLL Load(char *szFilename);
|
||||||
|
int DLL Save(char *szFilename);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Output( char * pcData, int nSize );
|
||||||
|
void Output( char c );
|
||||||
|
void Output( void );
|
||||||
|
unsigned char Input( void );
|
||||||
|
|
||||||
|
public:
|
||||||
|
int m_Xres, m_Yres;
|
||||||
|
unsigned short m_BitPerPixel;
|
||||||
|
unsigned short m_BytePerPixel;
|
||||||
|
unsigned char * m_pBitmap;
|
||||||
|
_BGR m_Pal[256];
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_NumPixel;
|
||||||
|
FILE * f;
|
||||||
|
int m_nCount;
|
||||||
|
char m_cBuf[32768];
|
||||||
|
};
|
||||||
|
|
||||||
|
#pragma pack(8)
|
||||||
|
|
||||||
|
}
|
|
@ -40,6 +40,9 @@
|
||||||
#include "gl/textures/gl_texture.h"
|
#include "gl/textures/gl_texture.h"
|
||||||
#include "c_cvars.h"
|
#include "c_cvars.h"
|
||||||
#include "gl/hqnx/hqx.h"
|
#include "gl/hqnx/hqx.h"
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include "gl/hqnx_asm/hqnx_asm.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
CUSTOM_CVAR(Int, gl_texture_hqresize, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
CUSTOM_CVAR(Int, gl_texture_hqresize, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||||
{
|
{
|
||||||
|
@ -179,6 +182,38 @@ static unsigned char *scaleNxHelper( void (*scaleNxFunction) ( uint32* , uint32*
|
||||||
return newBuffer;
|
return newBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// [BB] hqnx scaling is only supported with the MS compiler.
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
static unsigned char *hqNxAsmHelper( void (*hqNxFunction) ( int*, unsigned char*, int, int, int ),
|
||||||
|
const int N,
|
||||||
|
unsigned char *inputBuffer,
|
||||||
|
const int inWidth,
|
||||||
|
const int inHeight,
|
||||||
|
int &outWidth,
|
||||||
|
int &outHeight )
|
||||||
|
{
|
||||||
|
outWidth = N * inWidth;
|
||||||
|
outHeight = N *inHeight;
|
||||||
|
|
||||||
|
static int initdone = false;
|
||||||
|
|
||||||
|
if (!initdone)
|
||||||
|
{
|
||||||
|
HQnX_asm::InitLUTs();
|
||||||
|
initdone = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
HQnX_asm::CImage cImageIn;
|
||||||
|
cImageIn.SetImage(inputBuffer, inWidth, inHeight, 32);
|
||||||
|
cImageIn.Convert32To17();
|
||||||
|
|
||||||
|
unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4];
|
||||||
|
hqNxFunction( reinterpret_cast<int*>(cImageIn.m_pBitmap), newBuffer, cImageIn.m_Xres, cImageIn.m_Yres, outWidth*4 );
|
||||||
|
delete[] inputBuffer;
|
||||||
|
return newBuffer;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static unsigned char *hqNxHelper( void (*hqNxFunction) ( unsigned*, unsigned*, int, int ),
|
static unsigned char *hqNxHelper( void (*hqNxFunction) ( unsigned*, unsigned*, int, int ),
|
||||||
const int N,
|
const int N,
|
||||||
unsigned char *inputBuffer,
|
unsigned char *inputBuffer,
|
||||||
|
@ -203,6 +238,7 @@ static unsigned char *hqNxHelper( void (*hqNxFunction) ( unsigned*, unsigned*, i
|
||||||
return newBuffer;
|
return newBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// [BB] Upsamples the texture in inputBuffer, frees inputBuffer and returns
|
// [BB] Upsamples the texture in inputBuffer, frees inputBuffer and returns
|
||||||
|
@ -245,11 +281,11 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u
|
||||||
outWidth = inWidth;
|
outWidth = inWidth;
|
||||||
outHeight = inHeight;
|
outHeight = inHeight;
|
||||||
int type = gl_texture_hqresize;
|
int type = gl_texture_hqresize;
|
||||||
#if 0
|
#ifdef _MSC_VER
|
||||||
// hqNx does not preserve the alpha channel so fall back to ScaleNx for such textures
|
// ASM-hqNx does not preserve the alpha channel so fall back to C-version for such textures
|
||||||
if (hasAlpha && type > 3)
|
if (!hasAlpha && type > 3 && type <= 6)
|
||||||
{
|
{
|
||||||
type -= 3;
|
type += 3;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -267,6 +303,14 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u
|
||||||
return hqNxHelper( &hq3x_32, 3, inputBuffer, inWidth, inHeight, outWidth, outHeight );
|
return hqNxHelper( &hq3x_32, 3, inputBuffer, inWidth, inHeight, outWidth, outHeight );
|
||||||
case 6:
|
case 6:
|
||||||
return hqNxHelper( &hq4x_32, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight );
|
return hqNxHelper( &hq4x_32, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight );
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
case 7:
|
||||||
|
return hqNxAsmHelper( &HQnX_asm::hq2x_32, 2, inputBuffer, inWidth, inHeight, outWidth, outHeight );
|
||||||
|
case 8:
|
||||||
|
return hqNxAsmHelper( &HQnX_asm::hq3x_32, 3, inputBuffer, inWidth, inHeight, outWidth, outHeight );
|
||||||
|
case 9:
|
||||||
|
return hqNxAsmHelper( &HQnX_asm::hq4x_32, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return inputBuffer;
|
return inputBuffer;
|
||||||
|
|
Loading…
Reference in a new issue