togles: gamma fix, optimize texture convertation
This commit is contained in:
parent
cca56d5a6f
commit
3558b0e03c
@ -63,10 +63,16 @@ static void *l_egl = NULL;
|
|||||||
static void *l_gles = NULL;
|
static void *l_gles = NULL;
|
||||||
|
|
||||||
typedef void *(*t_glGetProcAddress)( const char * );
|
typedef void *(*t_glGetProcAddress)( const char * );
|
||||||
t_glGetProcAddress _glGetProcAddress;
|
|
||||||
|
|
||||||
typedef EGLBoolean (*t_eglBindAPI)(EGLenum api);
|
typedef EGLBoolean (*t_eglBindAPI)(EGLenum api);
|
||||||
|
typedef EGLBoolean (*t_eglInitialize)(EGLDisplay display, EGLint *major, EGLint *minor);
|
||||||
|
typedef EGLDisplay (*t_eglGetDisplay)(NativeDisplayType native_display);
|
||||||
|
typedef char const *(*t_eglQueryString)(EGLDisplay display, EGLint name);
|
||||||
|
|
||||||
t_eglBindAPI _eglBindAPI;
|
t_eglBindAPI _eglBindAPI;
|
||||||
|
t_glGetProcAddress _glGetProcAddress;
|
||||||
|
t_eglInitialize _eglInitialize;
|
||||||
|
t_eglGetDisplay _eglGetDisplay;
|
||||||
|
t_eglQueryString _eglQueryString;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -594,11 +600,25 @@ InitReturnVal_t CSDLMgr::Init()
|
|||||||
l_gles = dlopen("libGLESv3.so", RTLD_LAZY);
|
l_gles = dlopen("libGLESv3.so", RTLD_LAZY);
|
||||||
|
|
||||||
if( l_egl )
|
if( l_egl )
|
||||||
|
{
|
||||||
_glGetProcAddress = (t_glGetProcAddress)dlsym(l_egl, "eglGetProcAddress");
|
_glGetProcAddress = (t_glGetProcAddress)dlsym(l_egl, "eglGetProcAddress");
|
||||||
|
}
|
||||||
|
|
||||||
SET_GL_ATTR(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
SET_GL_ATTR(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
||||||
SET_GL_ATTR(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
SET_GL_ATTR(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||||
SET_GL_ATTR(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
SET_GL_ATTR(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||||
|
|
||||||
|
_eglInitialize = (t_eglInitialize)dlsym(l_egl, "eglInitialize");
|
||||||
|
_eglGetDisplay = (t_eglGetDisplay)dlsym(l_egl, "eglGetDisplay");
|
||||||
|
_eglQueryString = (t_eglQueryString)dlsym(l_egl, "eglQueryString");
|
||||||
|
|
||||||
|
if( _eglInitialize && _eglInitialize && _eglQueryString)
|
||||||
|
{
|
||||||
|
EGLDisplay display = _eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
|
if( _eglInitialize(display, NULL, NULL) != -1
|
||||||
|
&& strstr(_eglQueryString(display, EGL_EXTENSIONS) ,"EGL_KHR_gl_colorspace") )
|
||||||
|
SET_GL_ATTR(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1)
|
||||||
|
}
|
||||||
#elif ANDROID
|
#elif ANDROID
|
||||||
bool m_bOGL = false;
|
bool m_bOGL = false;
|
||||||
|
|
||||||
|
@ -312,12 +312,17 @@ ImageFormat D3DFormatToImageFormat( D3DFORMAT format )
|
|||||||
|
|
||||||
switch ( format )
|
switch ( format )
|
||||||
{
|
{
|
||||||
#if !defined( _X360 )
|
#ifdef TOGLES
|
||||||
|
case D3DFMT_R8G8B8:
|
||||||
|
return IMAGE_FORMAT_RGB888;
|
||||||
|
case D3DFMT_A8R8G8B8:
|
||||||
|
return IMAGE_FORMAT_RGBA8888;
|
||||||
|
#else
|
||||||
case D3DFMT_R8G8B8:
|
case D3DFMT_R8G8B8:
|
||||||
return IMAGE_FORMAT_BGR888;
|
return IMAGE_FORMAT_BGR888;
|
||||||
#endif
|
|
||||||
case D3DFMT_A8R8G8B8:
|
case D3DFMT_A8R8G8B8:
|
||||||
return IMAGE_FORMAT_BGRA8888;
|
return IMAGE_FORMAT_BGRA8888;
|
||||||
|
#endif
|
||||||
case D3DFMT_X8R8G8B8:
|
case D3DFMT_X8R8G8B8:
|
||||||
return IMAGE_FORMAT_BGRX8888;
|
return IMAGE_FORMAT_BGRX8888;
|
||||||
case D3DFMT_R5G6B5:
|
case D3DFMT_R5G6B5:
|
||||||
@ -426,6 +431,10 @@ D3DFORMAT ImageFormatToD3DFormat( ImageFormat format )
|
|||||||
#endif
|
#endif
|
||||||
case IMAGE_FORMAT_BGRA8888:
|
case IMAGE_FORMAT_BGRA8888:
|
||||||
return D3DFMT_A8R8G8B8;
|
return D3DFMT_A8R8G8B8;
|
||||||
|
case IMAGE_FORMAT_RGB888:
|
||||||
|
return D3DFMT_R8G8B8;
|
||||||
|
case IMAGE_FORMAT_RGBA8888:
|
||||||
|
return D3DFMT_A8R8G8B8;
|
||||||
case IMAGE_FORMAT_BGRX8888:
|
case IMAGE_FORMAT_BGRX8888:
|
||||||
return D3DFMT_X8R8G8B8;
|
return D3DFMT_X8R8G8B8;
|
||||||
case IMAGE_FORMAT_BGR565:
|
case IMAGE_FORMAT_BGR565:
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
|
|
||||||
enum NormalDecodeMode_t
|
enum NormalDecodeMode_t
|
||||||
{
|
{
|
||||||
NORMAL_DECODE_NONE = 0
|
NORMAL_DECODE_NONE = 0,
|
||||||
|
NORMAL_DECODE_ATI2N,
|
||||||
|
NORMAL_DECODE_ATI2N_ALPHA
|
||||||
};
|
};
|
||||||
|
|
||||||
// Forward declaration
|
// Forward declaration
|
||||||
|
@ -100,6 +100,9 @@ void CPersistentBuffer::Init( EGLMBufferType type,uint nSize )
|
|||||||
m_nOffset = 0;
|
m_nOffset = 0;
|
||||||
m_type = type;
|
m_type = type;
|
||||||
|
|
||||||
|
if( strcmp(gGL->glGetString(GL_RENDERER), "ARM") == 0 )
|
||||||
|
g_bUsePseudoBufs = true; // works faster with Mali gpu
|
||||||
|
|
||||||
switch ( type )
|
switch ( type )
|
||||||
{
|
{
|
||||||
case kGLMVertexBuffer: m_buffGLTarget = GL_ARRAY_BUFFER; break;
|
case kGLMVertexBuffer: m_buffGLTarget = GL_ARRAY_BUFFER; break;
|
||||||
|
@ -790,7 +790,8 @@ bool CGLMShaderPair::ValidateProgramPair()
|
|||||||
m_locVertexParams = gGL->glGetUniformLocation( m_program, "vc" );
|
m_locVertexParams = gGL->glGetUniformLocation( m_program, "vc" );
|
||||||
m_locVertexBoneParams = gGL->glGetUniformLocation( m_program, "vcbones" );
|
m_locVertexBoneParams = gGL->glGetUniformLocation( m_program, "vcbones" );
|
||||||
m_locVertexScreenParams = gGL->glGetUniformLocation( m_program, "vcscreen" );
|
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_nScreenWidthHeight = 0xFFFFFFFF;
|
||||||
|
|
||||||
|
@ -1106,7 +1106,7 @@ void CGLMTex::CalcTexelDataOffsetAndStrides( int sliceIndex, int x, int y, int z
|
|||||||
*zStrideOut = zStride;
|
*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 )
|
void CGLMTex::ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice )
|
||||||
{
|
{
|
||||||
@ -1142,7 +1142,6 @@ void CGLMTex::ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice )
|
|||||||
|
|
||||||
// interestingly enough, we can use the same path for both 2D and 3D fetch
|
// interestingly enough, we can use the same path for both 2D and 3D fetch
|
||||||
|
|
||||||
|
|
||||||
switch( target )
|
switch( target )
|
||||||
{
|
{
|
||||||
case GL_TEXTURE_CUBE_MAP:
|
case GL_TEXTURE_CUBE_MAP:
|
||||||
@ -1177,21 +1176,13 @@ void CGLMTex::ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice )
|
|||||||
|
|
||||||
gGL->glGenFramebuffers(1, &fbo);
|
gGL->glGenFramebuffers(1, &fbo);
|
||||||
gGL->glBindFramebuffer(GL_FRAMEBUFFER, 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;
|
GLenum fmt = format->m_glDataFormat;
|
||||||
if( fmt == GL_BGR )
|
GLenum dataType = format->m_glDataType;
|
||||||
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);
|
convert_texture(fmt, 0, 0, fmt, dataType, NULL);
|
||||||
GLint intformat = format->m_glDataFormat;
|
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);
|
||||||
GLenum _format = format->m_glDataFormat;
|
|
||||||
GLenum _type = format->m_glDataType;
|
|
||||||
|
|
||||||
// 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_READ_FRAMEBUFFER, Rfbo);
|
||||||
gGL->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, Dfbo);
|
gGL->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, Dfbo);
|
||||||
@ -3329,69 +3320,19 @@ static inline halffloat_t float_f2h(float f)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t srgb_table[256] = {0};
|
void convert_texture( GLenum &internalformat, GLsizei width, GLsizei height, GLenum &format, GLenum &type, void *data )
|
||||||
void pixel_srgb_inplace(GLvoid* pixels, GLuint size, GLuint width, GLuint height)
|
|
||||||
{
|
{
|
||||||
// return;
|
if( format == GL_BGRA ) format = GL_RGBA;
|
||||||
if(!srgb_table[255]) {
|
if( format == GL_BGR ) format = GL_RGB;
|
||||||
// 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( internalformat == GL_SRGB8 && format == GL_RGBA )
|
||||||
|
|
||||||
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 ))
|
|
||||||
internalformat = GL_SRGB8_ALPHA8;
|
internalformat = GL_SRGB8_ALPHA8;
|
||||||
|
|
||||||
if( format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA )
|
if( format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA )
|
||||||
internalformat = format;
|
internalformat = format;
|
||||||
|
|
||||||
if( internalformat == GL_SRGB8_ALPHA8 )
|
|
||||||
internalformat = GL_RGBA;
|
|
||||||
|
|
||||||
if( internalformat == GL_SRGB8 )
|
|
||||||
internalformat = GL_RGB;
|
|
||||||
|
|
||||||
if( data )
|
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 )
|
if( internalformat == GL_RGBA16 && !gGL->m_bHave_GL_EXT_texture_norm16 )
|
||||||
{
|
{
|
||||||
uint16_t *_data = (uint16_t*)data;
|
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+2] = _data[i+2] >> 8;
|
||||||
new_data[i+3] = _data[i+3] >> 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 )
|
if( internalformat == GL_RGBA16 && !gGL->m_bHave_GL_EXT_texture_norm16 )
|
||||||
{
|
{
|
||||||
internalformat = GL_RGBA;
|
internalformat = GL_RGBA;
|
||||||
format = GL_RGBA;
|
format = GL_RGBA;
|
||||||
type = GL_UNSIGNED_BYTE;
|
type = GL_UNSIGNED_BYTE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( type == GL_UNSIGNED_INT_8_8_8_8_REV )
|
if( type == GL_UNSIGNED_INT_8_8_8_8_REV )
|
||||||
type = GL_UNSIGNED_BYTE;
|
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) {
|
GLboolean isDXTc(GLenum format) {
|
||||||
@ -3587,26 +3489,10 @@ void CompressedTexImage2D(GLenum target, GLint level, GLenum internalformat,
|
|||||||
}
|
}
|
||||||
|
|
||||||
gGL->glTexImage2D(target, level, intformat, width, height, border, format, type, pixels);
|
gGL->glTexImage2D(target, level, intformat, width, height, border, format, type, pixels);
|
||||||
//TexImage2D( target, level, intformat, width, height, border, format, type, pixels );
|
|
||||||
if( data != pixels )
|
if( data != pixels )
|
||||||
free(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.
|
// TexSubImage should work properly on every driver stack and GPU--enabling by default.
|
||||||
ConVar gl_enabletexsubimage( "gl_enabletexsubimage", "1" );
|
ConVar gl_enabletexsubimage( "gl_enabletexsubimage", "1" );
|
||||||
|
|
||||||
@ -3664,12 +3550,9 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
|
|||||||
|
|
||||||
// allow use of subimage if the target is texture2D and it has already been teximage'd
|
// allow use of subimage if the target is texture2D and it has already been teximage'd
|
||||||
bool mayUseSubImage = false;
|
bool mayUseSubImage = false;
|
||||||
#ifdef ANDROID
|
|
||||||
if ( (target==GL_TEXTURE_2D) && (m_sliceFlags[ desc->m_sliceIndex ] & kSliceValid) )
|
if ( (target==GL_TEXTURE_2D) && (m_sliceFlags[ desc->m_sliceIndex ] & kSliceValid) )
|
||||||
{
|
mayUseSubImage = true;
|
||||||
mayUseSubImage = gl_enabletexsubimage.GetInt() != 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// check flavor, 2D, 3D, or cube map
|
// 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)
|
// we also have the choice to use subimage if this is a tex already created. (open question as to benefit)
|
||||||
@ -3776,8 +3659,6 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
|
|||||||
0, // border
|
0, // border
|
||||||
slice->m_storageSize, // imageSize
|
slice->m_storageSize, // imageSize
|
||||||
sliceAddress ); // data
|
sliceAddress ); // data
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -3789,14 +3670,15 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
|
|||||||
gGL->glPixelStorei( GL_UNPACK_SKIP_PIXELS, writeBox.xmin ); // in pixels
|
gGL->glPixelStorei( GL_UNPACK_SKIP_PIXELS, writeBox.xmin ); // in pixels
|
||||||
gGL->glPixelStorei( GL_UNPACK_SKIP_ROWS, writeBox.ymin ); // 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
|
desc->m_req.m_mip, // level
|
||||||
writeBox.xmin, // xoffset into dest
|
writeBox.xmin, // xoffset into dest
|
||||||
writeBox.ymin, // yoffset into dest
|
writeBox.ymin, // yoffset into dest
|
||||||
writeBox.xmax - writeBox.xmin, // width (was slice->m_xSize)
|
writeBox.xmax - writeBox.xmin, // width (was slice->m_xSize)
|
||||||
writeBox.ymax - writeBox.ymin, // height (was slice->m_ySize)
|
writeBox.ymax - writeBox.ymin, // height (was slice->m_ySize)
|
||||||
glDataFormat, // format
|
glDataFormat, // format
|
||||||
intformat,
|
|
||||||
glDataType, // type
|
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)
|
sliceAddress // data (will be offsetted by the SKIP_PIXELS and SKIP_ROWS - let GL do the math to find the first source texel)
|
||||||
);
|
);
|
||||||
@ -3809,7 +3691,9 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
|
|||||||
{
|
{
|
||||||
// uncompressed path
|
// uncompressed path
|
||||||
// http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/teximage2d.html
|
// 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
|
desc->m_req.m_mip, // level
|
||||||
intformat, // internalformat - don't use format->m_glIntFormat because we have the SRGB select going on above
|
intformat, // internalformat - don't use format->m_glIntFormat because we have the SRGB select going on above
|
||||||
slice->m_xSize, // width
|
slice->m_xSize, // width
|
||||||
@ -3854,8 +3738,7 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// uncompressed path
|
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);
|
||||||
// http://www.opengl.org/sdk/docs/man/xhtml/glTexImage3D.xml
|
|
||||||
gGL->glTexImage3D( target, // target
|
gGL->glTexImage3D( target, // target
|
||||||
desc->m_req.m_mip, // level
|
desc->m_req.m_mip, // level
|
||||||
intformat, // internalformat
|
intformat, // internalformat
|
||||||
|
@ -3187,9 +3187,6 @@ int D3DToGL::TranslateShader( uint32* code, CUtlBuffer *pBufDisassembledCode, bo
|
|||||||
m_bGeneratingDebugText = (options & D3DToGL_GeneratingDebugText) != 0;
|
m_bGeneratingDebugText = (options & D3DToGL_GeneratingDebugText) != 0;
|
||||||
m_bGenerateSRGBWriteSuffix = (options & D3DToGL_OptionSRGBWriteSuffix) != 0;
|
m_bGenerateSRGBWriteSuffix = (options & D3DToGL_OptionSRGBWriteSuffix) != 0;
|
||||||
|
|
||||||
/* 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_NumIndentTabs = 1; // start code indented one tab
|
||||||
m_nLoopDepth = 0;
|
m_nLoopDepth = 0;
|
||||||
|
|
||||||
@ -3908,7 +3905,7 @@ int D3DToGL::TranslateShader( uint32* code, CUtlBuffer *pBufDisassembledCode, bo
|
|||||||
if( FindSubcode("_gl_FrontSecondaryColor") && !m_bFrontSecondaryColor )
|
if( FindSubcode("_gl_FrontSecondaryColor") && !m_bFrontSecondaryColor )
|
||||||
StrcatToHeaderCode( "in vec4 _gl_FrontSecondaryColor;\n" );
|
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( "\nuniform float alpha_ref;\n" );
|
||||||
|
|
||||||
StrcatToHeaderCode( "\nvoid main()\n{\n" );
|
StrcatToHeaderCode( "\nvoid main()\n{\n" );
|
||||||
@ -3927,7 +3924,7 @@ int D3DToGL::TranslateShader( uint32* code, CUtlBuffer *pBufDisassembledCode, bo
|
|||||||
StrcatToALUCode( "gl_FragData[0].xyz = mix( gl_FragData[0].xyz, sRGBFragData, flSRGBWrite );\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" );
|
StrcatToALUCode( "if( gl_FragData[0].a < alpha_ref ) { discard; };\n" );
|
||||||
|
|
||||||
strcat_s( (char*)m_pBufALUCode->Base(), m_pBufALUCode->Size(), "}\n" );
|
strcat_s( (char*)m_pBufALUCode->Base(), m_pBufALUCode->Size(), "}\n" );
|
||||||
|
@ -74,6 +74,9 @@ const int kGLMHighWaterUndeleted = 2048;
|
|||||||
const int kDeletedTextureDim = 4;
|
const int kDeletedTextureDim = 4;
|
||||||
const uint32 g_garbageTextureBits[ 4 * kDeletedTextureDim * kDeletedTextureDim ] = { 0 };
|
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 [] =
|
char g_nullFragmentProgramText [] =
|
||||||
{
|
{
|
||||||
"#version 300 es\n"
|
"#version 300 es\n"
|
||||||
@ -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 )
|
GLMContext *GLMgr::NewContext( IDirect3DDevice9 *pDevice, GLMDisplayParams *params )
|
||||||
@ -2961,11 +2950,12 @@ void GLMContext::CleanupTex( GLenum texBind, GLMTexLayout* pLayout, GLuint tex )
|
|||||||
const int dataSize = ( chunks * chunks ) * pLayout->m_format->m_bytesPerSquareChunk;
|
const int dataSize = ( chunks * chunks ) * pLayout->m_format->m_bytesPerSquareChunk;
|
||||||
Assert( dataSize <= ( sizeof( uint32) * ARRAYSIZE( g_garbageTextureBits ) ) );
|
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
|
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 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 )
|
if( !m_AlphaTestEnable.GetData().enable )
|
||||||
gGL->glUniform1f( m_pBoundPair->m_locAlphaRef, 0.0 );
|
gGL->glUniform1f( m_pBoundPair->m_locAlphaRef, 0.0 );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user