mirror of
https://github.com/celisej567/source-engine.git
synced 2026-01-05 22:09:59 +03:00
Merge branch 'master' into windows
This commit is contained in:
@@ -95,11 +95,11 @@ void CPersistentBuffer::Init( EGLMBufferType type,uint nSize )
|
||||
{
|
||||
// Assert( gGL->m_bHave_GL_EXT_buffer_storage );
|
||||
// Assert( gGL->m_bHave_GL_ARB_map_buffer_range );
|
||||
|
||||
|
||||
m_nSize = nSize;
|
||||
m_nOffset = 0;
|
||||
m_type = type;
|
||||
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case kGLMVertexBuffer: m_buffGLTarget = GL_ARRAY_BUFFER; break;
|
||||
@@ -472,6 +472,9 @@ CGLMBuffer::CGLMBuffer( GLMContext *pCtx, EGLMBufferType type, uint size, uint o
|
||||
m_bPseudo = true;
|
||||
#endif
|
||||
|
||||
if( strcmp(gGL->m_pGLDriverStrings[cGLVendorString], "ARM") == 0 )
|
||||
g_bUsePseudoBufs = true; // works faster with Mali gpu
|
||||
|
||||
#if GL_ENABLE_INDEX_VERIFICATION
|
||||
m_BufferSpanManager.Init( m_pCtx, m_type, 512, m_nSize, m_bDynamic );
|
||||
|
||||
|
||||
@@ -350,11 +350,10 @@ void CGLMProgram::Compile( EGLMProgramLang lang )
|
||||
|
||||
// compile
|
||||
gGL->glCompileShader( glslDesc->m_object.glsl );
|
||||
|
||||
|
||||
|
||||
GLint isCompiled = 0;
|
||||
gGL->glGetShaderiv(glslDesc->m_object.glsl, GL_COMPILE_STATUS, &isCompiled);
|
||||
|
||||
|
||||
if(isCompiled == GL_FALSE)
|
||||
{
|
||||
GLint maxLength = 0;
|
||||
@@ -790,8 +789,9 @@ bool CGLMShaderPair::ValidateProgramPair()
|
||||
m_locVertexParams = gGL->glGetUniformLocation( m_program, "vc" );
|
||||
m_locVertexBoneParams = gGL->glGetUniformLocation( m_program, "vcbones" );
|
||||
m_locVertexScreenParams = gGL->glGetUniformLocation( m_program, "vcscreen" );
|
||||
m_locAlphaRef = gGL->glGetUniformLocation( m_program, "alpha_ref" );
|
||||
|
||||
if( !gGL->m_bHave_GL_QCOM_alpha_test )
|
||||
m_locAlphaRef = gGL->glGetUniformLocation( m_program, "alpha_ref" );
|
||||
|
||||
m_nScreenWidthHeight = 0xFFFFFFFF;
|
||||
|
||||
m_locVertexInteger0 = gGL->glGetUniformLocation( m_program, "i0" );
|
||||
|
||||
@@ -1106,7 +1106,7 @@ void CGLMTex::CalcTexelDataOffsetAndStrides( int sliceIndex, int x, int y, int z
|
||||
*zStrideOut = zStride;
|
||||
}
|
||||
|
||||
extern void convert_texture( GLint &internalformat, GLsizei width, GLsizei height, GLenum &format, GLenum &type, void *data );
|
||||
extern void convert_texture( GLenum &internalformat, GLsizei width, GLsizei height, GLenum &format, GLenum &type, void *data );
|
||||
|
||||
void CGLMTex::ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice )
|
||||
{
|
||||
@@ -1136,13 +1136,12 @@ void CGLMTex::ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice )
|
||||
|
||||
GLMTexFormatDesc *format = m_layout->m_format;
|
||||
GLenum target = m_layout->m_key.m_texGLTarget;
|
||||
|
||||
|
||||
void *sliceAddress = m_backing + m_layout->m_slices[ desc->m_sliceIndex ].m_storageOffset; // this would change for PBO
|
||||
//int sliceSize = m_layout->m_slices[ desc->m_sliceIndex ].m_storageSize;
|
||||
|
||||
// interestingly enough, we can use the same path for both 2D and 3D fetch
|
||||
|
||||
|
||||
|
||||
switch( target )
|
||||
{
|
||||
case GL_TEXTURE_CUBE_MAP:
|
||||
@@ -1174,25 +1173,17 @@ void CGLMTex::ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice )
|
||||
|
||||
gGL->glGetIntegerv( GL_DRAW_FRAMEBUFFER_BINDING, &Dfbo );
|
||||
gGL->glGetIntegerv( GL_READ_FRAMEBUFFER_BINDING, &Rfbo );
|
||||
|
||||
|
||||
gGL->glGenFramebuffers(1, &fbo);
|
||||
gGL->glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
gGL->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_ctx->m_samplers[0].m_pBoundTex->m_texName, 0);
|
||||
gGL->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, m_ctx->m_samplers[0].m_pBoundTex->m_texName, 0);
|
||||
|
||||
GLenum fmt = format->m_glDataFormat;
|
||||
if( fmt == GL_BGR )
|
||||
fmt = GL_RGB;
|
||||
else if( fmt == GL_BGRA )
|
||||
fmt = GL_RGBA;
|
||||
|
||||
gGL->glReadPixels(0, 0, m_layout->m_slices[ desc->m_sliceIndex ].m_xSize, m_layout->m_slices[ desc->m_sliceIndex ].m_ySize, fmt, format->m_glDataType == GL_UNSIGNED_INT_8_8_8_8_REV ? GL_UNSIGNED_BYTE : format->m_glDataType, sliceAddress);
|
||||
GLint intformat = format->m_glDataFormat;
|
||||
GLenum _format = format->m_glDataFormat;
|
||||
GLenum _type = format->m_glDataType;
|
||||
GLenum dataType = format->m_glDataType;
|
||||
|
||||
convert_texture(fmt, 0, 0, fmt, dataType, NULL);
|
||||
gGL->glReadPixels(0, 0, m_layout->m_slices[ desc->m_sliceIndex ].m_xSize, m_layout->m_slices[ desc->m_sliceIndex ].m_ySize, fmt, dataType, sliceAddress);
|
||||
|
||||
// TODO(nillerusr): Don't convert, should change m_format to another one
|
||||
convert_texture(intformat, m_layout->m_slices[ desc->m_sliceIndex ].m_xSize, m_layout->m_slices[ desc->m_sliceIndex ].m_ySize, _format, _type, sliceAddress);
|
||||
|
||||
gGL->glBindFramebuffer(GL_READ_FRAMEBUFFER, Rfbo);
|
||||
gGL->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, Dfbo);
|
||||
|
||||
@@ -3329,69 +3320,19 @@ static inline halffloat_t float_f2h(float f)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uint8_t srgb_table[256] = {0};
|
||||
void pixel_srgb_inplace(GLvoid* pixels, GLuint size, GLuint width, GLuint height)
|
||||
void convert_texture( GLenum &internalformat, GLsizei width, GLsizei height, GLenum &format, GLenum &type, void *data )
|
||||
{
|
||||
// return;
|
||||
if(!srgb_table[255]) {
|
||||
// create table
|
||||
for (int i=1; i<256; ++i) {
|
||||
srgb_table[i] = floorf(255.f*powf(i/255.f, 2.2f)+0.5f);
|
||||
}
|
||||
}
|
||||
uint8_t *data = (uint8_t*)pixels;
|
||||
int sz = width*height*size;
|
||||
for (int i=0; i < sz; i += size)
|
||||
{
|
||||
data[i] = srgb_table[data[i]];
|
||||
data[i+1] = srgb_table[data[i+1]];
|
||||
data[i+2] = srgb_table[data[i+2]];
|
||||
}
|
||||
}
|
||||
if( format == GL_BGRA ) format = GL_RGBA;
|
||||
if( format == GL_BGR ) format = GL_RGB;
|
||||
|
||||
|
||||
|
||||
void convert_texture( GLint &internalformat, GLsizei width, GLsizei height, GLenum &format, GLenum &type, void *data )
|
||||
{
|
||||
// printf("internalformat=%s format=%s type=%s\n", get_enum_str(internalformat), get_enum_str(format), get_enum_str(type));
|
||||
|
||||
if( internalformat == GL_SRGB8 && (format == GL_RGBA || format == GL_BGRA ))
|
||||
if( internalformat == GL_SRGB8 && format == GL_RGBA )
|
||||
internalformat = GL_SRGB8_ALPHA8;
|
||||
|
||||
if( format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA )
|
||||
internalformat = format;
|
||||
|
||||
// if( internalformat == GL_SRGB8_ALPHA8 )
|
||||
// internalformat = GL_RGBA;
|
||||
|
||||
// if( internalformat == GL_SRGB8 )
|
||||
// internalformat = GL_RGB;
|
||||
|
||||
if( data )
|
||||
{
|
||||
uint8_t *_data = (uint8_t*)data;
|
||||
|
||||
if( format == GL_BGR )
|
||||
{
|
||||
for( int i = 0; i < width*height*3; i+=3 )
|
||||
{
|
||||
uint8_t tmp = _data[i];
|
||||
_data[i] = _data[i+2];
|
||||
_data[i+2] = tmp;
|
||||
}
|
||||
format = GL_RGB;
|
||||
}
|
||||
else if( format == GL_BGRA )
|
||||
{
|
||||
for( int i = 0; i < width*height*4; i+=4 )
|
||||
{
|
||||
uint8_t tmp = _data[i];
|
||||
_data[i] = _data[i+2];
|
||||
_data[i+2] = tmp;
|
||||
}
|
||||
format = GL_RGBA;
|
||||
}
|
||||
|
||||
if( internalformat == GL_RGBA16 && !gGL->m_bHave_GL_EXT_texture_norm16 )
|
||||
{
|
||||
uint16_t *_data = (uint16_t*)data;
|
||||
@@ -3404,57 +3345,18 @@ void convert_texture( GLint &internalformat, GLsizei width, GLsizei height, GLen
|
||||
new_data[i+2] = _data[i+2] >> 8;
|
||||
new_data[i+3] = _data[i+3] >> 8;
|
||||
}
|
||||
|
||||
internalformat = GL_RGBA;
|
||||
format = GL_RGBA;
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
}
|
||||
else if( internalformat == GL_SRGB8_ALPHA8 )
|
||||
{
|
||||
// pixel_srgb_inplace( data, 4, width, height );
|
||||
internalformat = GL_RGBA;
|
||||
}
|
||||
else if( internalformat == GL_SRGB8 )
|
||||
{
|
||||
// pixel_srgb_inplace( data, 3, width, height );
|
||||
internalformat = GL_RGB;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if( format == GL_BGR )
|
||||
format = GL_RGB;
|
||||
else if( format == GL_BGRA )
|
||||
format = GL_RGBA;
|
||||
|
||||
if( internalformat == GL_RGBA16 && !gGL->m_bHave_GL_EXT_texture_norm16 )
|
||||
{
|
||||
internalformat = GL_RGBA;
|
||||
format = GL_RGBA;
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
}
|
||||
if( internalformat == GL_RGBA16 && !gGL->m_bHave_GL_EXT_texture_norm16 )
|
||||
{
|
||||
internalformat = GL_RGBA;
|
||||
format = GL_RGBA;
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
}
|
||||
|
||||
if( type == GL_UNSIGNED_INT_8_8_8_8_REV )
|
||||
type = GL_UNSIGNED_BYTE;
|
||||
|
||||
// printf("internalformat=%s format=%s type=%s\n==========================================\n", get_enum_str(internalformat), get_enum_str(format), get_enum_str(type));
|
||||
}
|
||||
|
||||
void TexImage2D(GLenum target,
|
||||
GLint level,
|
||||
GLint internalformat,
|
||||
GLsizei width,
|
||||
GLsizei height,
|
||||
GLint border,
|
||||
GLenum format,
|
||||
GLenum type,
|
||||
const void * data)
|
||||
{
|
||||
convert_texture( internalformat, width, height, format, type, data );
|
||||
|
||||
gGL->glTexImage2D(target, level, internalformat, width, height, border, format, type, data);
|
||||
}
|
||||
|
||||
GLboolean isDXTc(GLenum format) {
|
||||
@@ -3533,15 +3435,15 @@ GLvoid *uncompressDXTc(GLsizei width, GLsizei height, GLenum format, GLsizei ima
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
||||
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
|
||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
|
||||
DecompressBlockDXT1(x, y, width, (uint8_t*)src, transparent0, simpleAlpha, complexAlpha, pixels);
|
||||
DecompressBlockDXT1(x, y, width, (uint8_t*)src, transparent0, simpleAlpha, complexAlpha, (uint32_t*)pixels);
|
||||
break;
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
|
||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
|
||||
DecompressBlockDXT3(x, y, width, (uint8_t*)src, transparent0, simpleAlpha, complexAlpha, pixels);
|
||||
DecompressBlockDXT3(x, y, width, (uint8_t*)src, transparent0, simpleAlpha, complexAlpha, (uint32_t*)pixels);
|
||||
break;
|
||||
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
|
||||
DecompressBlockDXT5(x, y, width, (uint8_t*)src, transparent0, simpleAlpha, complexAlpha, pixels);
|
||||
DecompressBlockDXT5(x, y, width, (uint8_t*)src, transparent0, simpleAlpha, complexAlpha, (uint32_t*)pixels);
|
||||
break;
|
||||
}
|
||||
src+=blocksize;
|
||||
@@ -3587,26 +3489,10 @@ void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat,
|
||||
}
|
||||
|
||||
gGL->glTexImage2D(target, level, intformat, width, height, border, format, type, pixels);
|
||||
//TexImage2D( target, level, intformat, width, height, border, format, type, pixels );
|
||||
if( data != pixels )
|
||||
free(pixels);
|
||||
}
|
||||
|
||||
void TexSubImage2D( GLenum target,
|
||||
GLint level,
|
||||
GLint xoffset,
|
||||
GLint yoffset,
|
||||
GLsizei width,
|
||||
GLsizei height,
|
||||
GLenum format,
|
||||
GLint internalformat,
|
||||
GLenum type,
|
||||
const void * data)
|
||||
{
|
||||
convert_texture( internalformat, width, height, format, type, data );
|
||||
gGL->glTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, data);
|
||||
}
|
||||
|
||||
// TexSubImage should work properly on every driver stack and GPU--enabling by default.
|
||||
ConVar gl_enabletexsubimage( "gl_enabletexsubimage", "1" );
|
||||
|
||||
@@ -3659,15 +3545,14 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
|
||||
GLenum glDataFormat = format->m_glDataFormat; // this could change if expansion kicks in
|
||||
GLenum glDataType = format->m_glDataType;
|
||||
|
||||
GLMTexLayoutSlice *slice = &m_layout->m_slices[ desc->m_sliceIndex ];
|
||||
GLMTexLayoutSlice *slice = &m_layout->m_slices[ desc->m_sliceIndex ];
|
||||
void *sliceAddress = m_backing ? (m_backing + slice->m_storageOffset) : NULL; // this would change for PBO
|
||||
|
||||
// allow use of subimage if the target is texture2D and it has already been teximage'd
|
||||
bool mayUseSubImage = false;
|
||||
|
||||
if ( (target==GL_TEXTURE_2D) && (m_sliceFlags[ desc->m_sliceIndex ] & kSliceValid) )
|
||||
{
|
||||
// mayUseSubImage = gl_enabletexsubimage.GetInt() != 0;
|
||||
}
|
||||
mayUseSubImage = true;
|
||||
|
||||
// check flavor, 2D, 3D, or cube map
|
||||
// we also have the choice to use subimage if this is a tex already created. (open question as to benefit)
|
||||
@@ -3756,26 +3641,18 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
|
||||
|
||||
// adjust target to steer to the proper face, then fall through to the 2D texture path.
|
||||
target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + desc->m_req.m_face;
|
||||
|
||||
case GL_TEXTURE_2D:
|
||||
{
|
||||
{
|
||||
// check compressed or not
|
||||
if (format->m_chunkSize != 1)
|
||||
{
|
||||
Assert( writeWholeSlice ); //subimage not implemented in this path yet
|
||||
|
||||
// compressed path
|
||||
// http://www.opengl.org/sdk/docs/man/xhtml/glCompressedTexImage2D.xml
|
||||
CompressedTexImage2D( target, // target
|
||||
desc->m_req.m_mip, // level
|
||||
intformat, // internalformat - don't use format->m_glIntFormat because we have the SRGB select going on above
|
||||
slice->m_xSize, // width
|
||||
slice->m_ySize, // height
|
||||
0, // border
|
||||
slice->m_storageSize, // imageSize
|
||||
sliceAddress ); // data
|
||||
|
||||
|
||||
/* if( gGL->m_bHave_GL_EXT_texture_compression_dxt1 )
|
||||
gGL->glCompressedTexImage2D( target, desc->m_req.m_mip, intformat, slice->m_xSize, slice->m_ySize, 0, slice->m_storageSize, sliceAddress );
|
||||
else*/
|
||||
CompressedTexImage2D( target, desc->m_req.m_mip, intformat, slice->m_xSize, slice->m_ySize, 0, slice->m_storageSize, sliceAddress );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3786,15 +3663,16 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
|
||||
gGL->glPixelStorei( GL_UNPACK_ROW_LENGTH, slice->m_xSize ); // in pixels
|
||||
gGL->glPixelStorei( GL_UNPACK_SKIP_PIXELS, writeBox.xmin ); // in pixels
|
||||
gGL->glPixelStorei( GL_UNPACK_SKIP_ROWS, writeBox.ymin ); // in pixels
|
||||
|
||||
TexSubImage2D( target,
|
||||
|
||||
convert_texture(intformat, writeBox.xmax - writeBox.xmin, writeBox.ymax - writeBox.ymin, glDataFormat, glDataType, sliceAddress);
|
||||
|
||||
gGL->glTexSubImage2D( target,
|
||||
desc->m_req.m_mip, // level
|
||||
writeBox.xmin, // xoffset into dest
|
||||
writeBox.ymin, // yoffset into dest
|
||||
writeBox.xmax - writeBox.xmin, // width (was slice->m_xSize)
|
||||
writeBox.ymax - writeBox.ymin, // height (was slice->m_ySize)
|
||||
glDataFormat, // format
|
||||
intformat,
|
||||
glDataType, // type
|
||||
sliceAddress // data (will be offsetted by the SKIP_PIXELS and SKIP_ROWS - let GL do the math to find the first source texel)
|
||||
);
|
||||
@@ -3807,7 +3685,9 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
|
||||
{
|
||||
// uncompressed path
|
||||
// http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/teximage2d.html
|
||||
TexImage2D( target, // target
|
||||
convert_texture(intformat, m_layout->m_slices[ desc->m_sliceIndex ].m_xSize, m_layout->m_slices[ desc->m_sliceIndex ].m_ySize, glDataFormat, glDataType, noDataWrite ? NULL : sliceAddress);
|
||||
|
||||
gGL->glTexImage2D( target, // target
|
||||
desc->m_req.m_mip, // level
|
||||
intformat, // internalformat - don't use format->m_glIntFormat because we have the SRGB select going on above
|
||||
slice->m_xSize, // width
|
||||
@@ -3852,8 +3732,7 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
|
||||
}
|
||||
else
|
||||
{
|
||||
// uncompressed path
|
||||
// http://www.opengl.org/sdk/docs/man/xhtml/glTexImage3D.xml
|
||||
convert_texture(intformat, m_layout->m_slices[ desc->m_sliceIndex ].m_xSize, m_layout->m_slices[ desc->m_sliceIndex ].m_ySize, glDataFormat, glDataType, noDataWrite ? NULL : sliceAddress);
|
||||
gGL->glTexImage3D( target, // target
|
||||
desc->m_req.m_mip, // level
|
||||
intformat, // internalformat
|
||||
|
||||
Binary file not shown.
@@ -2148,23 +2148,32 @@ static uint PrintDoubleInt( char *pBuf, uint nBufSize, double f, uint nMinChars
|
||||
|
||||
if ( bAnyDigitsLeft )
|
||||
{
|
||||
uint n = remainder % 100U; remainder /= 100U; *reinterpret_cast<uint16*>(pDst - 1) = reinterpret_cast<const uint16*>(pDigits)[n];
|
||||
n = remainder % 100U; remainder /= 100U; *reinterpret_cast<uint16*>(pDst - 1 - 2) = reinterpret_cast<const uint16*>(pDigits)[n];
|
||||
uint n = remainder % 100U; remainder /= 100U;
|
||||
memcpy( reinterpret_cast<uint16*>(pDst - 1), &(reinterpret_cast<const uint16*>(pDigits)[n]), sizeof(uint16) );
|
||||
n = remainder % 100U; remainder /= 100U;
|
||||
memcpy( reinterpret_cast<uint16*>(pDst - 3), &(reinterpret_cast<const uint16*>(pDigits)[n]), sizeof(uint16) );
|
||||
Assert( remainder < 100U );
|
||||
*reinterpret_cast<uint16*>(pDst - 1 - 4) = reinterpret_cast<const uint16*>(pDigits)[remainder];
|
||||
memcpy( reinterpret_cast<uint16*>(pDst - 5), &(reinterpret_cast<const uint16*>(pDigits)[remainder]), sizeof(uint16) );
|
||||
pDst -= 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint n = remainder % 100U; remainder /= 100U; *reinterpret_cast<uint16*>(pDst - 1) = reinterpret_cast<const uint16*>(pDigits)[n]; --pDst; if ( ( n >= 10 ) || ( remainder ) ) --pDst;
|
||||
uint n = remainder % 100U; remainder /= 100U;
|
||||
memcpy( reinterpret_cast<uint16*>(pDst - 1), &(reinterpret_cast<const uint16*>(pDigits)[n]), sizeof(uint16) );
|
||||
--pDst; if ( ( n >= 10 ) || ( remainder ) ) --pDst;
|
||||
|
||||
if ( remainder )
|
||||
{
|
||||
n = remainder % 100U; remainder /= 100U; *reinterpret_cast<uint16*>(pDst - 1) = reinterpret_cast<const uint16*>(pDigits)[n]; --pDst; if ( ( n >= 10 ) || ( remainder ) ) --pDst;
|
||||
n = remainder % 100U; remainder /= 100U;
|
||||
memcpy( reinterpret_cast<uint16*>(pDst - 1), &(reinterpret_cast<const uint16*>(pDigits)[n]), sizeof(uint16) );
|
||||
|
||||
--pDst; if ( ( n >= 10 ) || ( remainder ) ) --pDst;
|
||||
|
||||
if ( remainder )
|
||||
{
|
||||
Assert( remainder < 100U );
|
||||
*reinterpret_cast<uint16*>(pDst - 1) = reinterpret_cast<const uint16*>(pDigits)[remainder]; --pDst; if ( remainder >= 10 ) --pDst;
|
||||
memcpy( reinterpret_cast<uint16*>(pDst - 1), &(reinterpret_cast<const uint16*>(pDigits)[remainder]), sizeof(uint16) );
|
||||
--pDst; if ( remainder >= 10 ) --pDst;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3186,10 +3195,6 @@ int D3DToGL::TranslateShader( uint32* code, CUtlBuffer *pBufDisassembledCode, bo
|
||||
m_bPutHexCodesAfterLines = (options & D3DToGL_PutHexCommentsAfterLines) != 0;
|
||||
m_bGeneratingDebugText = (options & D3DToGL_GeneratingDebugText) != 0;
|
||||
m_bGenerateSRGBWriteSuffix = (options & D3DToGL_OptionSRGBWriteSuffix) != 0;
|
||||
m_bGenerateSRGBWriteSuffix = false;
|
||||
|
||||
if( debugLabel && (V_strstr( debugLabel ,"vertexlit_and_unlit_generic_ps") || V_strstr( debugLabel ,"vertexlit_and_unlit_generic_bump_ps") ) )
|
||||
m_bGenerateSRGBWriteSuffix = true;
|
||||
|
||||
m_NumIndentTabs = 1; // start code indented one tab
|
||||
m_nLoopDepth = 0;
|
||||
@@ -3908,8 +3913,8 @@ int D3DToGL::TranslateShader( uint32* code, CUtlBuffer *pBufDisassembledCode, bo
|
||||
|
||||
if( FindSubcode("_gl_FrontSecondaryColor") && !m_bFrontSecondaryColor )
|
||||
StrcatToHeaderCode( "in vec4 _gl_FrontSecondaryColor;\n" );
|
||||
|
||||
if( m_iFragDataCount && bVertexShader )
|
||||
|
||||
if( !gGL->m_bHave_GL_QCOM_alpha_test && m_iFragDataCount && bVertexShader )
|
||||
StrcatToHeaderCode( "\nuniform float alpha_ref;\n" );
|
||||
|
||||
StrcatToHeaderCode( "\nvoid main()\n{\n" );
|
||||
@@ -3921,18 +3926,18 @@ int D3DToGL::TranslateShader( uint32* code, CUtlBuffer *pBufDisassembledCode, bo
|
||||
// sRGB Write suffix
|
||||
if ( m_bGenerateSRGBWriteSuffix )
|
||||
{
|
||||
// StrcatToALUCode( "vec3 sRGBFragData;\n" );
|
||||
// StrcatToALUCode( "sRGBFragData.xyz = log( gl_FragData[0].xyz );\n" );
|
||||
// StrcatToALUCode( "sRGBFragData.xyz = sRGBFragData.xyz * vec3( 0.754545f, 0.754545f, 0.754545f );\n" );
|
||||
// StrcatToALUCode( "sRGBFragData.xyz = exp( sRGBFragData.xyz );\n" );
|
||||
StrcatToALUCode( "gl_FragData[0].xyz = pow(gl_FragData[0].xyz, vec3(1.0/2.2));\n" );
|
||||
StrcatToALUCode( "vec3 sRGBFragData;\n" );
|
||||
StrcatToALUCode( "sRGBFragData.xyz = log( gl_FragData[0].xyz );\n" );
|
||||
StrcatToALUCode( "sRGBFragData.xyz = sRGBFragData.xyz * vec3( 0.454545f, 0.454545f, 0.454545f );\n" );
|
||||
StrcatToALUCode( "sRGBFragData.xyz = exp( sRGBFragData.xyz );\n" );
|
||||
StrcatToALUCode( "gl_FragData[0].xyz = mix( gl_FragData[0].xyz, sRGBFragData, flSRGBWrite );\n" );
|
||||
}
|
||||
|
||||
if( m_iFragDataCount && bVertexShader )
|
||||
|
||||
if( !gGL->m_bHave_GL_QCOM_alpha_test && m_iFragDataCount && bVertexShader )
|
||||
StrcatToALUCode( "if( gl_FragData[0].a < alpha_ref ) { discard; };\n" );
|
||||
|
||||
strcat_s( (char*)m_pBufALUCode->Base(), m_pBufALUCode->Size(), "}\n" );
|
||||
|
||||
|
||||
// Put all of the strings together for final program ( pHeaderCode + pAttribCode + pParamCode + pALUCode )
|
||||
StrcatToHeaderCode( (char*)m_pBufAttribCode->Base() );
|
||||
StrcatToHeaderCode( (char*)m_pBufParamCode->Base() );
|
||||
|
||||
@@ -1201,9 +1201,10 @@ static void FillD3DCaps9( const GLMRendererInfoFields &glmRendererInfo, D3DCAPS9
|
||||
pCaps->MaxPixelShader30InstructionSlots = 0;
|
||||
|
||||
#if DX_TO_GL_ABSTRACTION
|
||||
pCaps->FakeSRGBWrite = !glmRendererInfo.m_hasGammaWrites;
|
||||
pCaps->CanDoSRGBReadFromRTs = !glmRendererInfo.m_cantAttachSRGB;
|
||||
pCaps->FakeSRGBWrite = true;//!glmRendererInfo.m_hasGammaWrites;
|
||||
pCaps->CanDoSRGBReadFromRTs = true;//!glmRendererInfo.m_cantAttachSRGB;
|
||||
pCaps->MixedSizeTargets = glmRendererInfo.m_hasMixedAttachmentSizes;
|
||||
pCaps->SupportInt16Format = gGL->m_bHave_GL_EXT_texture_norm16;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -3762,12 +3763,16 @@ static uint32 CentroidMaskFromName( bool bPixelShader, const char *pName )
|
||||
static int ShadowDepthSamplerMaskFromName( const char *pName )
|
||||
{
|
||||
if ( !pName )
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
|
||||
if ( V_stristr( pName, "water_ps" ) )
|
||||
{
|
||||
return (1<<7);
|
||||
}
|
||||
else if ( V_stristr( pName, "skin_ps" ) )
|
||||
{
|
||||
return (1<<4);
|
||||
}
|
||||
else if ( V_stristr( pName, "infected_ps" ) )
|
||||
{
|
||||
return (1<<1);
|
||||
@@ -3794,7 +3799,7 @@ static int ShadowDepthSamplerMaskFromName( const char *pName )
|
||||
}
|
||||
else if ( V_stristr( pName, "worldtwotextureblend_ps" ) )
|
||||
{
|
||||
return (1<<7);
|
||||
return (1<<2);
|
||||
}
|
||||
else if ( V_stristr( pName, "teeth_flashlight_ps" ) )
|
||||
{
|
||||
@@ -3811,27 +3816,27 @@ static int ShadowDepthSamplerMaskFromName( const char *pName )
|
||||
else if ( V_stristr( pName, "deferred_global_light_ps" ) )
|
||||
{
|
||||
return (1<<14);
|
||||
}
|
||||
}
|
||||
else if ( V_stristr( pName, "global_lit_simple_ps" ) )
|
||||
{
|
||||
return (1<<14);
|
||||
}
|
||||
}
|
||||
else if ( V_stristr( pName, "lightshafts_ps" ) )
|
||||
{
|
||||
return (1<<1);
|
||||
}
|
||||
}
|
||||
else if ( V_stristr( pName, "multiblend_combined_ps" ) )
|
||||
{
|
||||
return (1<<14);
|
||||
}
|
||||
}
|
||||
else if ( V_stristr( pName, "multiblend_ps" ) )
|
||||
{
|
||||
return (1<<14);
|
||||
}
|
||||
}
|
||||
else if ( V_stristr( pName, "customhero_ps" ) )
|
||||
{
|
||||
return (1<<14);
|
||||
}
|
||||
}
|
||||
|
||||
// This shader doesn't have a shadow depth map sampler
|
||||
return 0;
|
||||
|
||||
@@ -206,7 +206,7 @@ void ToGLDisconnectLibraries()
|
||||
static void GetOpenGLVersion(int *major, int *minor, int *patch)
|
||||
{
|
||||
*major = *minor = *patch = 0;
|
||||
static CDynamicFunctionOpenGL< true, const GLubyte *( APIENTRY *)(GLenum name), const GLubyte * > glGetString("glGetString");
|
||||
static CDynamicFunctionOpenGL< true, const GLubyte *( _APIENTRY *)(GLenum name), const GLubyte * > glGetString("glGetString");
|
||||
if (glGetString)
|
||||
{
|
||||
const char *version = (const char *) glGetString(GL_VERSION);
|
||||
@@ -271,7 +271,7 @@ static bool CheckOpenGLExtension_internal(const char *ext, const int coremajor,
|
||||
}
|
||||
|
||||
// okay, see if the GL_EXTENSIONS string reports it.
|
||||
static CDynamicFunctionOpenGL< true, const GLubyte *( APIENTRY *)(GLenum name), const GLubyte * > glGetString("glGetString");
|
||||
static CDynamicFunctionOpenGL< true, const GLubyte *( _APIENTRY *)(GLenum name), const GLubyte * > glGetString("glGetString");
|
||||
if (!glGetString)
|
||||
return false;
|
||||
|
||||
@@ -284,7 +284,7 @@ static bool CheckOpenGLExtension_internal(const char *ext, const int coremajor,
|
||||
#if _WIN32
|
||||
if (!ptr)
|
||||
{
|
||||
static CDynamicFunctionOpenGL< true, const char *( APIENTRY *)( ), const char * > wglGetExtensionsStringEXT("wglGetExtensionsStringEXT");
|
||||
static CDynamicFunctionOpenGL< true, const char *( _APIENTRY *)( ), const char * > wglGetExtensionsStringEXT("wglGetExtensionsStringEXT");
|
||||
if (wglGetExtensionsStringEXT)
|
||||
{
|
||||
extensions = wglGetExtensionsStringEXT();
|
||||
@@ -485,12 +485,12 @@ COpenGLEntryPoints::COpenGLEntryPoints()
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OSX
|
||||
/*#ifndef OSX
|
||||
if ( !m_bHave_GL_EXT_texture_sRGB_decode )
|
||||
{
|
||||
Error( "Required OpenGL extension \"GL_EXT_texture_sRGB_decode\" is not supported. Please update your OpenGL driver.\n" );
|
||||
}
|
||||
#endif
|
||||
#endif*/
|
||||
}
|
||||
|
||||
COpenGLEntryPoints::~COpenGLEntryPoints()
|
||||
|
||||
@@ -74,6 +74,9 @@ const int kGLMHighWaterUndeleted = 2048;
|
||||
const int kDeletedTextureDim = 4;
|
||||
const uint32 g_garbageTextureBits[ 4 * kDeletedTextureDim * kDeletedTextureDim ] = { 0 };
|
||||
|
||||
extern void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
|
||||
extern void convert_texture( GLenum &internalformat, GLsizei width, GLsizei height, GLenum &format, GLenum &type, void *data );
|
||||
|
||||
char g_nullFragmentProgramText [] =
|
||||
{
|
||||
"#version 300 es\n"
|
||||
@@ -218,7 +221,7 @@ void APIENTRY GL_Debug_Output_Callback(GLenum source, GLenum type, GLuint id, GL
|
||||
return;
|
||||
}
|
||||
|
||||
if ( gl_debug_output.GetBool() || type == GL_DEBUG_TYPE_ERROR_ARB )
|
||||
if ( gl_debug_output.GetBool() || type == GL_DEBUG_TYPE_ERROR_ARB || type == GL_DEBUG_SEVERITY_MEDIUM_ARB )
|
||||
{
|
||||
Msg( "GL: [%s][%s][%s][%d]: %s\n", sSource, sType, sSeverity, id, message );
|
||||
}
|
||||
@@ -449,20 +452,6 @@ GLMgr::~GLMgr()
|
||||
{
|
||||
}
|
||||
|
||||
extern void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat,
|
||||
GLsizei width, GLsizei height, GLint border,
|
||||
GLsizei imageSize, const GLvoid *data);
|
||||
|
||||
extern void TexImage2D(GLenum target,
|
||||
GLint level,
|
||||
GLint internalformat,
|
||||
GLsizei width,
|
||||
GLsizei height,
|
||||
GLint border,
|
||||
GLenum format,
|
||||
GLenum type,
|
||||
const void * data);
|
||||
|
||||
//===============================================================================
|
||||
|
||||
GLMContext *GLMgr::NewContext( IDirect3DDevice9 *pDevice, GLMDisplayParams *params )
|
||||
@@ -678,7 +667,7 @@ void GLMContext::DumpCaps( void )
|
||||
#define dumpfield_hex( fff ) printf( "\n %-30s : 0x%08x", #fff, (int) m_caps.fff )
|
||||
#define dumpfield_str( fff ) printf( "\n %-30s : %s", #fff, m_caps.fff )
|
||||
|
||||
printf("\n-------------------------------- context caps for context %08x", (uint)this);
|
||||
printf("\n-------------------------------- context caps for context %zx", (size_t)this);
|
||||
|
||||
dumpfield( m_fullscreen );
|
||||
dumpfield( m_accelerated );
|
||||
@@ -1740,14 +1729,13 @@ void GLMContext::PreloadTex( CGLMTex *tex, bool force )
|
||||
0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f };
|
||||
|
||||
static int indices[] = { 0, 1, 2 };
|
||||
|
||||
static unsigned short indices[] = { 0, 1, 2 };
|
||||
|
||||
gGL->glEnableVertexAttribArray( 0 );
|
||||
|
||||
gGL->glVertexAttribPointer( 0, 3, GL_FLOAT, 0, 0, posns );
|
||||
|
||||
gGL->glDrawRangeElements( GL_TRIANGLES, 0, 2, 3, GL_UNSIGNED_INT, indices);
|
||||
gGL->glDrawRangeElements( GL_TRIANGLES, 0, 2, 3, GL_UNSIGNED_SHORT, indices);
|
||||
|
||||
gGL->glDisableVertexAttribArray( 0 );
|
||||
|
||||
@@ -2961,11 +2949,12 @@ void GLMContext::CleanupTex( GLenum texBind, GLMTexLayout* pLayout, GLuint tex )
|
||||
const int dataSize = ( chunks * chunks ) * pLayout->m_format->m_bytesPerSquareChunk;
|
||||
Assert( dataSize <= ( sizeof( uint32) * ARRAYSIZE( g_garbageTextureBits ) ) );
|
||||
|
||||
CompressedTexImage2D( texBind, i, pLayout->m_format->m_glIntFormat, mipDim, mipDim, 0, dataSize, 0 );
|
||||
CompressedTexImage2D( texBind, i, pLayout->m_format->m_glIntFormat, mipDim, mipDim, 0, dataSize, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
TexImage2D( texBind, i, pLayout->m_format->m_glIntFormat, mipDim, mipDim, 0, pLayout->m_format->m_glDataFormat, pLayout->m_format->m_glDataType, 0 );
|
||||
convert_texture( pLayout->m_format->m_glIntFormat, mipDim, mipDim, pLayout->m_format->m_glDataFormat, pLayout->m_format->m_glDataType, NULL );
|
||||
gGL->glTexImage2D( texBind, i, pLayout->m_format->m_glIntFormat, mipDim, mipDim, 0, pLayout->m_format->m_glDataFormat, pLayout->m_format->m_glDataType, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4517,7 +4506,7 @@ void GLMContext::GenDebugFontTex( void )
|
||||
|
||||
//-----------------------------------------------------
|
||||
// fetch elements of font data and make texels... we're doing the whole slab so we don't really need the stride info
|
||||
unsigned long *destTexelPtr = (unsigned long *)lockAddress;
|
||||
uint32 *destTexelPtr = (uint32 *)lockAddress;
|
||||
|
||||
for( int index = 0; index < 16384; index++ )
|
||||
{
|
||||
@@ -4936,11 +4925,11 @@ void GLMContext::DrawRangeElementsNonInline( GLenum mode, GLuint start, GLuint e
|
||||
if ( pIndexBuf->m_bPseudo )
|
||||
{
|
||||
// you have to pass actual address, not offset
|
||||
indicesActual = (void*)( (int)indicesActual + (int)pIndexBuf->m_pPseudoBuf );
|
||||
indicesActual = (void*)( (intp)indicesActual + (intp)pIndexBuf->m_pPseudoBuf );
|
||||
}
|
||||
if (pIndexBuf->m_bUsingPersistentBuffer)
|
||||
{
|
||||
indicesActual = (void*)( (int)indicesActual + (int)pIndexBuf->m_nPersistentBufferStartOffset );
|
||||
indicesActual = (void*)( (intp)indicesActual + (intp)pIndexBuf->m_nPersistentBufferStartOffset );
|
||||
}
|
||||
|
||||
#if GL_ENABLE_INDEX_VERIFICATION
|
||||
|
||||
@@ -480,7 +480,7 @@ FORCEINLINE void GLMContext::FlushDrawStates( uint nStartIndex, uint nEndIndex,
|
||||
}
|
||||
|
||||
|
||||
if( m_pBoundPair->m_locAlphaRef )
|
||||
if( !gGL->m_bHave_GL_QCOM_alpha_test && m_pBoundPair->m_locAlphaRef )
|
||||
{
|
||||
if( !m_AlphaTestEnable.GetData().enable )
|
||||
gGL->glUniform1f( m_pBoundPair->m_locAlphaRef, 0.0 );
|
||||
@@ -573,7 +573,7 @@ FORCEINLINE void GLMContext::FlushDrawStates( uint nStartIndex, uint nEndIndex,
|
||||
|
||||
SetBufAndVertexAttribPointer( nIndex, pBuf->GetHandle(),
|
||||
pStream->m_stride, pDeclElem->m_gldecl.m_datatype, pDeclElem->m_gldecl.m_normalized, pDeclElem->m_gldecl.m_nCompCount,
|
||||
reinterpret_cast< const GLvoid * >( reinterpret_cast< int >( pBuf->m_pPseudoBuf ) + nBufOffset ),
|
||||
reinterpret_cast< const GLvoid * >( reinterpret_cast< intp >( pBuf->m_pPseudoBuf ) + nBufOffset ),
|
||||
pBuf->m_nRevision );
|
||||
|
||||
if ( !( m_lastKnownVertexAttribMask & nMask ) )
|
||||
|
||||
Reference in New Issue
Block a user