Permalink
Browse files

Add support for GL_EXT_texture_integer.

  • Loading branch information...
1 parent 55ce562 commit a931ad7557c3fa42565a269386bd09e5b0b9f196 @gimhael gimhael committed Feb 1, 2016
@@ -1196,6 +1196,14 @@ void R_UploadImage( const byte **dataArray, int numLayers, int numMips,
GL_R32F : GL_ALPHA32F_ARB;
}
}
+ else if ( image->bits & ( IF_RGBA32UI ) )
+ {
+ if( !glConfig2.textureIntegerAvailable ) {
+ ri.Printf( PRINT_WARNING, "WARNING: integer image '%s' cannot be loaded\n", image->name );
+ }
+ internalFormat = GL_RGBA32UI;
+ format = GL_RGBA_INTEGER;
+ }
else if ( IsImageCompressed( image->bits ) )
{
if( !GLEW_EXT_texture_compression_dxt1 &&
@@ -1405,10 +1413,12 @@ void R_UploadImage( const byte **dataArray, int numLayers, int numMips,
switch ( image->type )
{
case GL_TEXTURE_3D:
- glTexSubImage3D( GL_TEXTURE_3D, 0, 0, 0, i,
- scaledWidth, scaledHeight, 1,
- format, GL_UNSIGNED_BYTE,
- scaledBuffer );
+ if( scaledBuffer ) {
+ glTexSubImage3D( GL_TEXTURE_3D, 0, 0, 0, i,
+ scaledWidth, scaledHeight, 1,
+ format, GL_UNSIGNED_BYTE,
+ scaledBuffer );
+ }
break;
case GL_TEXTURE_CUBE_MAP:
glTexImage2D( target + i, 0, internalFormat, scaledWidth, scaledHeight, 0, format, GL_UNSIGNED_BYTE,
@@ -1842,9 +1852,13 @@ image_t *R_Create3DImage( const char *name,
image->width = width;
image->height = height;
- pics = (const byte**) ri.Hunk_AllocateTempMemory( depth * sizeof(const byte *) );
- for( i = 0; i < depth; i++ ) {
- pics[i] = pic + i * width * height * sizeof(u8vec4_t);
+ if( pic ) {
+ pics = (const byte**) ri.Hunk_AllocateTempMemory( depth * sizeof(const byte *) );
+ for( i = 0; i < depth; i++ ) {
+ pics[i] = pic + i * width * height * sizeof(u8vec4_t);
+ }
+ } else {
+ pics = nullptr;
}
image->bits = bits;
@@ -1853,7 +1867,9 @@ image_t *R_Create3DImage( const char *name,
R_UploadImage( pics, depth, 1, image );
- ri.Hunk_FreeTempMemory( pics );
+ if( pics ) {
+ ri.Hunk_FreeTempMemory( pics );
+ }
if( r_exportTextures->integer ) {
R_ExportTexture( image );
@@ -98,6 +98,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
cvar_t *r_ext_vertex_array_object;
cvar_t *r_ext_half_float_pixel;
cvar_t *r_ext_texture_float;
+ cvar_t *r_ext_texture_integer;
cvar_t *r_ext_texture_rg;
cvar_t *r_ext_texture_filter_anisotropic;
cvar_t *r_ext_packed_depth_stencil;
@@ -311,6 +312,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
return false;
}
+ glState.tileStep[ 0 ] = TILE_SIZE * ( 1.0f / glConfig.vidWidth );
+ glState.tileStep[ 1 ] = TILE_SIZE * ( 1.0f / glConfig.vidHeight );
+
GL_CheckErrors();
strcpy( renderer_buffer, glConfig.renderer_string );
@@ -1072,6 +1076,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
r_ext_vertex_array_object = ri.Cvar_Get( "r_ext_vertex_array_object", "1", CVAR_CHEAT | CVAR_LATCH );
r_ext_half_float_pixel = ri.Cvar_Get( "r_ext_half_float_pixel", "1", CVAR_CHEAT | CVAR_LATCH );
r_ext_texture_float = ri.Cvar_Get( "r_ext_texture_float", "1", CVAR_CHEAT | CVAR_LATCH );
+ r_ext_texture_integer = ri.Cvar_Get( "r_ext_texture_integer", "1", CVAR_CHEAT | CVAR_LATCH );
r_ext_texture_rg = ri.Cvar_Get( "r_ext_texture_rg", "1", CVAR_CHEAT | CVAR_LATCH );
r_ext_texture_filter_anisotropic = ri.Cvar_Get( "r_ext_texture_filter_anisotropic", "4", CVAR_LATCH | CVAR_ARCHIVE );
r_ext_packed_depth_stencil = ri.Cvar_Get( "r_ext_packed_depth_stencil", "1", CVAR_CHEAT | CVAR_LATCH );
@@ -527,7 +527,8 @@ static inline void halfToFloat( const f16vec4_t in, vec4_t out )
IF_BC1 = BIT( 20 ),
IF_BC3 = BIT( 21 ),
IF_BC4 = BIT( 22 ),
- IF_BC5 = BIT( 23 )
+ IF_BC5 = BIT( 23 ),
+ IF_RGBA32UI = BIT( 24 )
};
enum class filterType_t
@@ -2851,6 +2852,7 @@ static inline void halfToFloat( const f16vec4_t in, vec4_t out )
extern cvar_t *r_ext_vertex_array_object;
extern cvar_t *r_ext_half_float_pixel;
extern cvar_t *r_ext_texture_float;
+ extern cvar_t *r_ext_texture_integer;
extern cvar_t *r_ext_texture_rg;
extern cvar_t *r_ext_texture_filter_anisotropic;
extern cvar_t *r_ext_packed_depth_stencil;
@@ -393,6 +393,7 @@ struct glconfig2_t
bool drawBuffersAvailable;
bool textureHalfFloatAvailable;
bool textureFloatAvailable;
+ bool textureIntegerAvailable;
bool textureRGAvailable;
int maxDrawBuffers;
@@ -1090,6 +1090,7 @@ static void GLimp_InitExtensions()
glConfig2.textureHalfFloatAvailable = LOAD_EXTENSION_WITH_CVAR(ARB_half_float_pixel, r_ext_half_float_pixel);
glConfig2.textureFloatAvailable = LOAD_EXTENSION_WITH_CVAR(ARB_texture_float, r_ext_texture_float);
+ glConfig2.textureIntegerAvailable = LOAD_EXTENSION_WITH_CVAR(EXT_texture_integer, r_ext_texture_integer);
glConfig2.textureRGAvailable = LOAD_EXTENSION_WITH_CVAR(ARB_texture_rg, r_ext_texture_rg);
// TODO figure out what was the problem with MESA

0 comments on commit a931ad7

Please sign in to comment.