killed globalImages->BindNull(). More cleanups from vkneo

This commit is contained in:
Robert Beckebans 2017-09-10 15:27:31 +02:00
parent f4dd96e404
commit 38bcf14c7b
9 changed files with 284 additions and 512 deletions

View file

@ -825,16 +825,6 @@ CONSOLE_COMMAND( reloadLanguage, "reload language dict", NULL )
#include "../renderer/Image.h"
/*
=================
Com_StartBuild_f
=================
*/
CONSOLE_COMMAND( startBuild, "prepares to make a build", NULL )
{
globalImages->StartBuild();
}
/*
=================
Com_FinishBuild_f
@ -846,7 +836,6 @@ CONSOLE_COMMAND( finishBuild, "finishes the build process", NULL )
{
game->CacheDictionaryMedia( NULL );
}
globalImages->FinishBuild( ( args.Argc() > 1 ) );
}
/*

View file

@ -61,8 +61,7 @@ public:
//---------------------------
private:
void AdvanceSurf();
void EmitSurfaces( float modelMatrix[16], float modelViewMatrix[16],
bool depthHack, bool allowFullScreenStereoDepth, bool linkAsEntity );
void EmitSurfaces( float modelMatrix[16], float modelViewMatrix[16], bool depthHack, bool allowFullScreenStereoDepth, bool linkAsEntity );
guiModelSurface_t* surf;

View file

@ -3,7 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2013-2014 Robert Beckebans
Copyright (C) 2013-2017 Robert Beckebans
Copyright (C) 2016-2017 Dustin Land
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -311,7 +311,6 @@ public:
// Platform specific implementations
//---------------------------------------------
#if defined( ID_VULKAN )
void CreateFromSwapImage( VkImage image, VkImageView imageView, VkFormat format, const VkExtent2D& extent );
VkImage GetImage() const
@ -497,9 +496,6 @@ public:
// reloads all apropriate images after a vid_restart
void ReloadImages( bool all );
// disable the active texture unit
void BindNull();
// Called only by renderSystem::BeginLevelLoad
void BeginLevelLoad();
@ -511,10 +507,6 @@ public:
// Loads unloaded level images
int LoadLevelImages( bool pacifier );
// used to clear and then write the dds conversion batch file
void StartBuild();
void FinishBuild( bool removeDups = false );
void PrintMemInfo( MemInfo_t* mi );
// built-in images
@ -577,8 +569,6 @@ public:
extern idImageManager* globalImages; // pointer to global list for the rest of the system
int MakePowerOfTwo( int num );
/*
====================================================================

View file

@ -63,7 +63,7 @@ void R_ReloadImages_f( const idCmdArgs& args )
}
else
{
common->Printf( "USAGE: reloadImages <all>\n" );
idLib::Printf( "USAGE: reloadImages <all>\n" );
return;
}
}
@ -81,7 +81,6 @@ typedef struct
/*
=======================
R_QsortImageSizes
=======================
*/
static int R_QsortImageSizes( const void* a, const void* b )
@ -105,7 +104,6 @@ static int R_QsortImageSizes( const void* a, const void* b )
/*
=======================
R_QsortImageName
=======================
*/
static int R_QsortImageName( const void* a, const void* b )
@ -180,20 +178,23 @@ void R_ListImages_f( const idCmdArgs& args )
if( failed )
{
common->Printf( "usage: listImages [ sorted | namesort | unloaded | duplicated | showOverSized ]\n" );
idLib::Printf( "usage: listImages [ sorted | namesort | unloaded | duplicated | showOverSized ]\n" );
return;
}
const char* header = " -w-- -h-- filt -fmt-- wrap size --name-------\n";
common->Printf( "\n%s", header );
idLib::Printf( "\n%s", header );
totalSize = 0;
sortedImage_t* sortedArray = ( sortedImage_t* )alloca( sizeof( sortedImage_t ) * globalImages->images.Num() );
idList< idImage* >& images = globalImages->images;
const int numImages = images.Num();
for( i = 0 ; i < globalImages->images.Num() ; i++ )
sortedImage_t* sortedArray = ( sortedImage_t* )alloca( sizeof( sortedImage_t ) * numImages );
for( i = 0 ; i < numImages; i++ )
{
image = globalImages->images[ i ];
image = images[ i ];
if( uncompressedOnly )
{
@ -211,14 +212,14 @@ void R_ListImages_f( const idCmdArgs& args )
if( duplicated )
{
int j;
for( j = i + 1 ; j < globalImages->images.Num() ; j++ )
for( j = i + 1 ; j < numImages ; j++ )
{
if( idStr::Icmp( image->GetName(), globalImages->images[ j ]->GetName() ) == 0 )
if( idStr::Icmp( image->GetName(), images[ j ]->GetName() ) == 0 )
{
break;
}
}
if( j == globalImages->images.Num() )
if( j == numImages )
{
continue;
}
@ -232,7 +233,7 @@ void R_ListImages_f( const idCmdArgs& args )
}
else
{
common->Printf( "%4i:", i );
idLib::Printf( "%4i:", i );
image->Print();
}
totalSize += image->StorageSize();
@ -252,20 +253,20 @@ void R_ListImages_f( const idCmdArgs& args )
partialSize = 0;
for( i = 0 ; i < count ; i++ )
{
common->Printf( "%4i:", sortedArray[i].index );
idLib::Printf( "%4i:", sortedArray[i].index );
sortedArray[i].image->Print();
partialSize += sortedArray[i].image->StorageSize();
if( ( ( i + 1 ) % 10 ) == 0 )
{
common->Printf( "-------- %5.1f of %5.1f megs --------\n",
idLib::Printf( "-------- %5.1f of %5.1f megs --------\n",
partialSize / ( 1024 * 1024.0 ), totalSize / ( 1024 * 1024.0 ) );
}
}
}
common->Printf( "%s", header );
common->Printf( " %i images (%i total)\n", count, globalImages->images.Num() );
common->Printf( " %5.1f total megabytes of images\n\n\n", totalSize / ( 1024 * 1024.0 ) );
idLib::Printf( "%s", header );
idLib::Printf( " %i images (%i total)\n", count, numImages );
idLib::Printf( " %5.1f total megabytes of images\n\n\n", totalSize / ( 1024 * 1024.0 ) );
}
/*
@ -280,7 +281,7 @@ idImage* idImageManager::AllocImage( const char* name )
{
if( strlen( name ) >= MAX_IMAGE_NAME )
{
common->Error( "idImageManager::AllocImage: \"%s\" is too long\n", name );
idLib::Error( "idImageManager::AllocImage: \"%s\" is too long\n", name );
}
int hash = idStr( name ).FileNameHash();
@ -356,62 +357,6 @@ idImage* idImageManager::ImageFromFunction( const char* _name, void ( *generator
return image;
}
/*
===============
GetImageWithParameters
==============
*/
idImage* idImageManager::GetImageWithParameters( const char* _name, textureFilter_t filter, textureRepeat_t repeat, textureUsage_t usage, cubeFiles_t cubeMap ) const
{
if( !_name || !_name[0] || idStr::Icmp( _name, "default" ) == 0 || idStr::Icmp( _name, "_default" ) == 0 )
{
declManager->MediaPrint( "DEFAULTED\n" );
return globalImages->defaultImage;
}
if( idStr::Icmpn( _name, "fonts", 5 ) == 0 || idStr::Icmpn( _name, "newfonts", 8 ) == 0 )
{
usage = TD_FONT;
}
if( idStr::Icmpn( _name, "lights", 6 ) == 0 )
{
usage = TD_LIGHT;
}
// strip any .tga file extensions from anywhere in the _name, including image program parameters
idStrStatic< MAX_OSPATH > name = _name;
name.Replace( ".tga", "" );
name.BackSlashesToSlashes();
int hash = name.FileNameHash();
for( int i = imageHash.First( hash ); i != -1; i = imageHash.Next( i ) )
{
idImage* image = images[i];
if( name.Icmp( image->GetName() ) == 0 )
{
// the built in's, like _white and _flat always match the other options
if( name[0] == '_' )
{
return image;
}
if( image->cubeFiles != cubeMap )
{
common->Error( "Image '%s' has been referenced with conflicting cube map states", _name );
}
if( image->filter != filter || image->repeat != repeat )
{
// we might want to have the system reset these parameters on every bind and
// share the image data
continue;
}
if( image->usage != usage )
{
// If an image is used differently then we need 2 copies of it because usage affects the way it's compressed and swizzled
continue;
}
return image;
}
}
return NULL;
}
/*
===============
ImageFromFile
@ -460,7 +405,7 @@ idImage* idImageManager::ImageFromFile( const char* _name, textureFilter_t filte
}
if( image->cubeFiles != cubeMap )
{
common->Error( "Image '%s' has been referenced with conflicting cube map states", _name );
idLib::Error( "Image '%s' has been referenced with conflicting cube map states", _name );
}
if( image->filter != filter || image->repeat != repeat )
@ -628,13 +573,9 @@ PurgeAllImages
*/
void idImageManager::PurgeAllImages()
{
int i;
idImage* image;
for( i = 0; i < images.Num() ; i++ )
for( int i = 0; i < images.Num() ; i++ )
{
image = images[i];
image->PurgeImage();
images[ i ]->PurgeImage();
}
}
@ -645,9 +586,9 @@ ReloadImages
*/
void idImageManager::ReloadImages( bool all )
{
for( int i = 0 ; i < globalImages->images.Num() ; i++ )
for( int i = 0 ; i < images.Num() ; i++ )
{
globalImages->images[ i ]->Reload( all );
images[ i ]->Reload( all );
}
}
@ -663,9 +604,9 @@ void R_CombineCubeImages_f( const idCmdArgs& args )
{
if( args.Argc() != 2 )
{
common->Printf( "usage: combineCubeImages <baseName>\n" );
common->Printf( " combines basename[1-6][0001-9999].tga to basenameCM[0001-9999].tga\n" );
common->Printf( " 1: forward 2:right 3:back 4:left 5:up 6:down\n" );
idLib::Printf( "usage: combineCubeImages <baseName>\n" );
idLib::Printf( " combines basename[1-6][0001-9999].tga to basenameCM[0001-9999].tga\n" );
idLib::Printf( " 1: forward 2:right 3:back 4:left 5:up 6:down\n" );
return;
}
@ -683,12 +624,12 @@ void R_CombineCubeImages_f( const idCmdArgs& args )
{
sprintf( filename, "%s%i%04i.tga", baseName.c_str(), orderRemap[side], frameNum );
common->Printf( "reading %s\n", filename );
idLib::Printf( "reading %s\n", filename );
R_LoadImage( filename, &pics[side], &width, &height, NULL, true );
if( !pics[side] )
{
common->Printf( "not found.\n" );
idLib::Printf( "not found.\n" );
break;
}
@ -736,25 +677,12 @@ void R_CombineCubeImages_f( const idCmdArgs& args )
}
sprintf( filename, "%sCM%04i.tga", baseName.c_str(), frameNum );
common->Printf( "writing %s\n", filename );
idLib::Printf( "writing %s\n", filename );
R_WriteTGA( filename, combined, width, height * 6 );
}
common->SetRefreshOnPrint( false );
}
/*
===============
BindNull
===============
*/
void idImageManager::BindNull()
{
RENDERLOG_PRINTF( "BindNull()\n" );
}
/*
===============
Init
@ -856,7 +784,7 @@ void idImageManager::Preload( const idPreloadManifest& manifest, const bool& map
if( preLoad_Images.GetBool() && manifest.NumResources() > 0 )
{
// preload this levels images
common->Printf( "Preloading images...\n" );
idLib::Printf( "Preloading images...\n" );
preloadingMapImages = mapPreload;
int start = Sys_Milliseconds();
int numLoaded = 0;
@ -873,8 +801,8 @@ void idImageManager::Preload( const idPreloadManifest& manifest, const bool& map
}
//fileSystem->StopPreload();
int end = Sys_Milliseconds();
common->Printf( "%05d images preloaded ( or were already loaded ) in %5.1f seconds\n", numLoaded, ( end - start ) * 0.001 );
common->Printf( "----------------------------------------\n" );
idLib::Printf( "%05d images preloaded ( or were already loaded ) in %5.1f seconds\n", numLoaded, ( end - start ) * 0.001 );
idLib::Printf( "----------------------------------------\n" );
preloadingMapImages = false;
}
}
@ -918,34 +846,16 @@ void idImageManager::EndLevelLoad()
{
insideLevelLoad = false;
common->Printf( "----- idImageManager::EndLevelLoad -----\n" );
idLib::Printf( "----- idImageManager::EndLevelLoad -----\n" );
int start = Sys_Milliseconds();
int loadCount = LoadLevelImages( true );
int end = Sys_Milliseconds();
common->Printf( "%5i images loaded in %5.1f seconds\n", loadCount, ( end - start ) * 0.001 );
common->Printf( "----------------------------------------\n" );
idLib::Printf( "%5i images loaded in %5.1f seconds\n", loadCount, ( end - start ) * 0.001 );
idLib::Printf( "----------------------------------------\n" );
//R_ListImages_f( idCmdArgs( "sorted sorted", false ) );
}
/*
===============
idImageManager::StartBuild
===============
*/
void idImageManager::StartBuild()
{
}
/*
===============
idImageManager::FinishBuild
===============
*/
void idImageManager::FinishBuild( bool removeDups )
{
}
/*
===============
idImageManager::PrintMemInfo

View file

@ -3,8 +3,9 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2013-2016 Robert Beckebans
Copyright (C) 2013-2017 Robert Beckebans
Copyright (C) 2014-2016 Kot in Action Creative Artel
Copyright (C) 2016-2017 Dustin Land
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -94,7 +95,6 @@ idImage::DeriveOpts
*/
ID_INLINE void idImage::DeriveOpts()
{
if( opts.format == FMT_NONE )
{
opts.colorFormat = CFM_DEFAULT;
@ -152,7 +152,9 @@ ID_INLINE void idImage::DeriveOpts()
opts.gammaMips = true;
break;
case TD_LIGHT:
// RB: don't destroy lighting
// RB: TODO check binary format version
// D3 BFG assets require RGB565 but it introduces color banding
// mods would prefer FMT_RGBA8
opts.format = FMT_RGB565; //FMT_RGBA8;
opts.gammaMips = true;
break;
@ -213,172 +215,6 @@ void idImage::AllocImage( const idImageOpts& imgOpts, textureFilter_t tf, textur
AllocImage();
}
/*
================
GenerateImage
================
*/
void idImage::GenerateImage( const byte* pic, int width, int height, textureFilter_t filterParm, textureRepeat_t repeatParm, textureUsage_t usageParm, int msaaSamples )
{
PurgeImage();
filter = filterParm;
repeat = repeatParm;
usage = usageParm;
cubeFiles = CF_2D;
opts.textureType = ( msaaSamples > 0 ) ? TT_2D_MULTISAMPLE : TT_2D;
opts.width = width;
opts.height = height;
opts.numLevels = 0;
opts.samples = textureSamples_t( msaaSamples );
DeriveOpts();
// if we don't have a rendering context, just return after we
// have filled in the parms. We must have the values set, or
// an image match from a shader before the render starts would miss
// the generated texture
if( !R_IsInitialized() )
{
return;
}
// RB: allow pic == NULL for internal framebuffer images
if( pic == NULL || opts.textureType == TT_2D_MULTISAMPLE )
{
AllocImage();
}
else
{
idBinaryImage im( GetName() );
// foresthale 2014-05-30: give a nice progress display when binarizing
commonLocal.LoadPacifierBinarizeFilename( GetName() , "generated image" );
if( opts.numLevels > 1 )
{
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.height * 4 / 3 );
}
else
{
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.height );
}
im.Load2DFromMemory( width, height, pic, opts.numLevels, opts.format, opts.colorFormat, opts.gammaMips );
commonLocal.LoadPacifierBinarizeEnd();
AllocImage();
for( int i = 0; i < im.NumImages(); i++ )
{
const bimageImage_t& img = im.GetImageHeader( i );
const byte* data = im.GetImageData( i );
SubImageUpload( img.level, 0, 0, img.destZ, img.width, img.height, data );
}
}
// RB end
}
/*
====================
GenerateCubeImage
Non-square cube sides are not allowed
====================
*/
void idImage::GenerateCubeImage( const byte* pic[6], int size, textureFilter_t filterParm, textureUsage_t usageParm )
{
PurgeImage();
filter = filterParm;
repeat = TR_CLAMP;
usage = usageParm;
cubeFiles = CF_NATIVE;
opts.textureType = TT_CUBIC;
opts.width = size;
opts.height = size;
opts.numLevels = 0;
DeriveOpts();
// if we don't have a rendering context, just return after we
// have filled in the parms. We must have the values set, or
// an image match from a shader before the render starts would miss
// the generated texture
if( !R_IsInitialized() )
{
return;
}
idBinaryImage im( GetName() );
// foresthale 2014-05-30: give a nice progress display when binarizing
commonLocal.LoadPacifierBinarizeFilename( GetName(), "generated cube image" );
if( opts.numLevels > 1 )
{
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.width * 6 * 4 / 3 );
}
else
{
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.width * 6 );
}
im.LoadCubeFromMemory( size, pic, opts.numLevels, opts.format, opts.gammaMips );
commonLocal.LoadPacifierBinarizeEnd();
AllocImage();
for( int i = 0; i < im.NumImages(); i++ )
{
const bimageImage_t& img = im.GetImageHeader( i );
const byte* data = im.GetImageData( i );
SubImageUpload( img.level, 0, 0, img.destZ, img.width, img.height, data );
}
}
// RB begin
void idImage::GenerateShadowArray( int width, int height, textureFilter_t filterParm, textureRepeat_t repeatParm, textureUsage_t usageParm )
{
PurgeImage();
filter = filterParm;
repeat = repeatParm;
usage = usageParm;
cubeFiles = CF_2D_ARRAY;
opts.textureType = TT_2D_ARRAY;
opts.width = width;
opts.height = height;
opts.numLevels = 0;
DeriveOpts();
// if we don't have a rendering context, just return after we
// have filled in the parms. We must have the values set, or
// an image match from a shader before the render starts would miss
// the generated texture
if( !R_IsInitialized() )
{
return;
}
//idBinaryImage im( GetName() );
//im.Load2DFromMemory( width, height, pic, opts.numLevels, opts.format, opts.colorFormat, opts.gammaMips );
AllocImage();
/*
for( int i = 0; i < im.NumImages(); i++ )
{
const bimageImage_t& img = im.GetImageHeader( i );
const byte* data = im.GetImageData( i );
SubImageUpload( img.level, 0, 0, img.destZ, img.width, img.height, data );
}
*/
}
// RB end
/*
===============
GetGeneratedName
@ -436,12 +272,11 @@ void idImage::ActuallyLoadImage( bool fromBackEnd )
}
else
{
// RB begin
// RB: added CF_2D_ARRAY
if( cubeFiles == CF_2D_ARRAY )
{
opts.textureType = TT_2D_ARRAY;
}
// RB end
else if( cubeFiles != CF_2D )
{
opts.textureType = TT_CUBIC;
@ -649,7 +484,6 @@ void idImage::ActuallyLoadImage( bool fromBackEnd )
AllocImage();
for( int i = 0; i < im.NumImages(); i++ )
{
const bimageImage_t& img = im.GetImageHeader( i );
@ -658,80 +492,6 @@ void idImage::ActuallyLoadImage( bool fromBackEnd )
}
}
/*
================
MakePowerOfTwo
================
*/
int MakePowerOfTwo( int num )
{
int pot;
for( pot = 1; pot < num; pot <<= 1 )
{
}
return pot;
}
/*
=============
RB_UploadScratchImage
if rows = cols * 6, assume it is a cube map animation
=============
*/
void idImage::UploadScratch( const byte* data, int cols, int rows )
{
// if rows = cols * 6, assume it is a cube map animation
if( rows == cols * 6 )
{
rows /= 6;
const byte* pic[6];
for( int i = 0; i < 6; i++ )
{
pic[i] = data + cols * rows * 4 * i;
}
if( opts.textureType != TT_CUBIC || usage != TD_LOOKUP_TABLE_RGBA )
{
GenerateCubeImage( pic, cols, TF_LINEAR, TD_LOOKUP_TABLE_RGBA );
return;
}
if( opts.width != cols || opts.height != rows )
{
opts.width = cols;
opts.height = rows;
AllocImage();
}
SetSamplerState( TF_LINEAR, TR_CLAMP );
for( int i = 0; i < 6; i++ )
{
SubImageUpload( 0, 0, 0, i, opts.width, opts.height, pic[i] );
}
}
else
{
if( opts.textureType != TT_2D || usage != TD_LOOKUP_TABLE_RGBA )
{
GenerateImage( data, cols, rows, TF_LINEAR, TR_REPEAT, TD_LOOKUP_TABLE_RGBA );
return;
}
if( opts.width != cols || opts.height != rows )
{
opts.width = cols;
opts.height = rows;
AllocImage();
}
SetSamplerState( TF_LINEAR, TR_REPEAT );
SubImageUpload( 0, 0, 0, 0, opts.width, opts.height, data );
}
}
/*
==================
StorageSize
@ -924,3 +684,224 @@ void idImage::SetSamplerState( textureFilter_t tf, textureRepeat_t tr )
glBindTexture( ( opts.textureType == TT_CUBIC ) ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D, texnum );
SetTexParameters();
}
/*
================
GenerateImage
================
*/
void idImage::GenerateImage( const byte* pic, int width, int height, textureFilter_t filterParm, textureRepeat_t repeatParm, textureUsage_t usageParm, int msaaSamples )
{
PurgeImage();
filter = filterParm;
repeat = repeatParm;
usage = usageParm;
cubeFiles = CF_2D;
opts.textureType = ( msaaSamples > 0 ) ? TT_2D_MULTISAMPLE : TT_2D;
opts.width = width;
opts.height = height;
opts.numLevels = 0;
opts.samples = textureSamples_t( msaaSamples );
DeriveOpts();
// if we don't have a rendering context, just return after we
// have filled in the parms. We must have the values set, or
// an image match from a shader before the render starts would miss
// the generated texture
if( !R_IsInitialized() )
{
return;
}
// RB: allow pic == NULL for internal framebuffer images
if( pic == NULL || opts.textureType == TT_2D_MULTISAMPLE )
{
AllocImage();
}
else
{
idBinaryImage im( GetName() );
// foresthale 2014-05-30: give a nice progress display when binarizing
commonLocal.LoadPacifierBinarizeFilename( GetName() , "generated image" );
if( opts.numLevels > 1 )
{
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.height * 4 / 3 );
}
else
{
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.height );
}
im.Load2DFromMemory( width, height, pic, opts.numLevels, opts.format, opts.colorFormat, opts.gammaMips );
commonLocal.LoadPacifierBinarizeEnd();
AllocImage();
for( int i = 0; i < im.NumImages(); i++ )
{
const bimageImage_t& img = im.GetImageHeader( i );
const byte* data = im.GetImageData( i );
SubImageUpload( img.level, 0, 0, img.destZ, img.width, img.height, data );
}
}
// RB end
}
/*
====================
GenerateCubeImage
Non-square cube sides are not allowed
====================
*/
void idImage::GenerateCubeImage( const byte* pic[6], int size, textureFilter_t filterParm, textureUsage_t usageParm )
{
PurgeImage();
filter = filterParm;
repeat = TR_CLAMP;
usage = usageParm;
cubeFiles = CF_NATIVE;
opts.textureType = TT_CUBIC;
opts.width = size;
opts.height = size;
opts.numLevels = 0;
DeriveOpts();
// if we don't have a rendering context, just return after we
// have filled in the parms. We must have the values set, or
// an image match from a shader before the render starts would miss
// the generated texture
if( !R_IsInitialized() )
{
return;
}
idBinaryImage im( GetName() );
// foresthale 2014-05-30: give a nice progress display when binarizing
commonLocal.LoadPacifierBinarizeFilename( GetName(), "generated cube image" );
if( opts.numLevels > 1 )
{
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.width * 6 * 4 / 3 );
}
else
{
commonLocal.LoadPacifierBinarizeProgressTotal( opts.width * opts.width * 6 );
}
im.LoadCubeFromMemory( size, pic, opts.numLevels, opts.format, opts.gammaMips );
commonLocal.LoadPacifierBinarizeEnd();
AllocImage();
for( int i = 0; i < im.NumImages(); i++ )
{
const bimageImage_t& img = im.GetImageHeader( i );
const byte* data = im.GetImageData( i );
SubImageUpload( img.level, 0, 0, img.destZ, img.width, img.height, data );
}
}
// RB begin
void idImage::GenerateShadowArray( int width, int height, textureFilter_t filterParm, textureRepeat_t repeatParm, textureUsage_t usageParm )
{
PurgeImage();
filter = filterParm;
repeat = repeatParm;
usage = usageParm;
cubeFiles = CF_2D_ARRAY;
opts.textureType = TT_2D_ARRAY;
opts.width = width;
opts.height = height;
opts.numLevels = 0;
DeriveOpts();
// if we don't have a rendering context, just return after we
// have filled in the parms. We must have the values set, or
// an image match from a shader before the render starts would miss
// the generated texture
if( !R_IsInitialized() )
{
return;
}
//idBinaryImage im( GetName() );
//im.Load2DFromMemory( width, height, pic, opts.numLevels, opts.format, opts.colorFormat, opts.gammaMips );
AllocImage();
/*
for( int i = 0; i < im.NumImages(); i++ )
{
const bimageImage_t& img = im.GetImageHeader( i );
const byte* data = im.GetImageData( i );
SubImageUpload( img.level, 0, 0, img.destZ, img.width, img.height, data );
}
*/
}
// RB end
/*
=============
RB_UploadScratchImage
if rows = cols * 6, assume it is a cube map animation
=============
*/
void idImage::UploadScratch( const byte* data, int cols, int rows )
{
// if rows = cols * 6, assume it is a cube map animation
if( rows == cols * 6 )
{
rows /= 6;
const byte* pic[6];
for( int i = 0; i < 6; i++ )
{
pic[i] = data + cols * rows * 4 * i;
}
if( opts.textureType != TT_CUBIC || usage != TD_LOOKUP_TABLE_RGBA )
{
GenerateCubeImage( pic, cols, TF_LINEAR, TD_LOOKUP_TABLE_RGBA );
return;
}
if( opts.width != cols || opts.height != rows )
{
opts.width = cols;
opts.height = rows;
AllocImage();
}
SetSamplerState( TF_LINEAR, TR_CLAMP );
for( int i = 0; i < 6; i++ )
{
SubImageUpload( 0, 0, 0, i, opts.width, opts.height, pic[i] );
}
}
else
{
if( opts.textureType != TT_2D || usage != TD_LOOKUP_TABLE_RGBA )
{
GenerateImage( data, cols, rows, TF_LINEAR, TR_REPEAT, TD_LOOKUP_TABLE_RGBA );
return;
}
if( opts.width != cols || opts.height != rows )
{
opts.width = cols;
opts.height = rows;
AllocImage();
}
SetSamplerState( TF_LINEAR, TR_REPEAT );
SubImageUpload( 0, 0, 0, 0, opts.width, opts.height, data );
}
}

View file

@ -419,7 +419,6 @@ static bool R_ParseImageProgram_r( idLexer& src, byte** pic, int* width, int* he
ID_TIME_T* timestamps, textureUsage_t* usage )
{
idToken token;
float scale;
ID_TIME_T timestamp;
src.ReadToken( &token );
@ -454,7 +453,7 @@ static bool R_ParseImageProgram_r( idLexer& src, byte** pic, int* width, int* he
src.ReadToken( &token );
AppendToken( token );
scale = token.GetFloatValue();
float scale = token.GetFloatValue();
// process it
if( pic )

View file

@ -440,7 +440,6 @@ void idRenderBackend::DBG_ShowIntensity()
glRasterPos2f( 0, 0 );
glPopMatrix();
GL_Color( 1, 1, 1 );
globalImages->BindNull();
glMatrixMode( GL_MODELVIEW );
glDrawPixels( renderSystem->GetWidth(), renderSystem->GetHeight(), GL_RGBA , GL_UNSIGNED_BYTE, colorReadback );
@ -478,7 +477,6 @@ void idRenderBackend::DBG_ShowDepthBuffer()
GL_State( GLS_DEPTHFUNC_ALWAYS );
GL_Color( 1, 1, 1 );
globalImages->BindNull();
depthReadback = R_StaticAlloc( renderSystem->GetWidth() * renderSystem->GetHeight() * 4, TAG_RENDER_TOOLS );
memset( depthReadback, 0, renderSystem->GetWidth() * renderSystem->GetHeight() * 4 );
@ -677,16 +675,12 @@ void idRenderBackend::DBG_ShowSilhouette()
}
// clear all triangle edges to black
globalImages->BindNull();
// RB begin
// RB
renderProgManager.BindShader_Color();
// RB end
GL_Color( 0, 0, 0 );
GL_State( GLS_DEPTHFUNC_ALWAYS | GLS_POLYMODE_LINE );
GL_Cull( CT_TWO_SIDED );
DBG_RenderDrawSurfListWithFunction( viewDef->drawSurfs, viewDef->numDrawSurfs );
@ -925,8 +919,6 @@ void idRenderBackend::DBG_ShowViewEntitys( viewEntity_t* vModels )
common->Printf( "\n" );
}
globalImages->BindNull();
renderProgManager.BindShader_Color();
GL_Color( 1, 1, 1 );
@ -1009,7 +1001,6 @@ void idRenderBackend::DBG_ShowTexturePolarity( drawSurf_t** drawSurfs, int numDr
{
return;
}
globalImages->BindNull();
GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
@ -1088,7 +1079,6 @@ void idRenderBackend::DBG_ShowUnsmoothedTangents( drawSurf_t** drawSurfs, int nu
{
return;
}
globalImages->BindNull();
GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
@ -1150,7 +1140,6 @@ void idRenderBackend::DBG_ShowTangentSpace( drawSurf_t** drawSurfs, int numDrawS
{
return;
}
globalImages->BindNull();
GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
@ -1216,7 +1205,6 @@ void idRenderBackend::DBG_ShowVertexColor( drawSurf_t** drawSurfs, int numDrawSu
{
return;
}
globalImages->BindNull();
// RB begin
renderProgManager.BindShader_VertexColor();
@ -1276,8 +1264,6 @@ void idRenderBackend::DBG_ShowNormals( drawSurf_t** drawSurfs, int numDrawSurfs
return;
}
globalImages->BindNull();
if( !r_debugLineDepthTest.GetBool() )
{
GL_State( GLS_POLYMODE_LINE | GLS_DEPTHFUNC_ALWAYS );
@ -1387,8 +1373,6 @@ void idRenderBackend::DBG_ShowTextureVectors( drawSurf_t** drawSurfs, int numDra
GL_State( GLS_DEPTHFUNC_LESS );
globalImages->BindNull();
for( int i = 0; i < numDrawSurfs; i++ )
{
drawSurf_t* drawSurf = drawSurfs[i];
@ -1496,8 +1480,6 @@ void idRenderBackend::DBG_ShowDominantTris( drawSurf_t** drawSurfs, int numDrawS
GL_PolygonOffset( -1, -2 );
glEnable( GL_POLYGON_OFFSET_LINE );
globalImages->BindNull();
for( i = 0; i < numDrawSurfs; i++ )
{
drawSurf = drawSurfs[i];
@ -1560,8 +1542,6 @@ void idRenderBackend::DBG_ShowEdges( drawSurf_t** drawSurfs, int numDrawSurfs )
return;
}
globalImages->BindNull();
GL_State( GLS_DEPTHFUNC_ALWAYS );
for( i = 0; i < numDrawSurfs; i++ )
@ -1668,8 +1648,6 @@ void idRenderBackend::DBG_ShowLights()
GL_State( GLS_DEFAULT );
globalImages->BindNull();
renderProgManager.BindShader_Color();
GL_Cull( CT_TWO_SIDED );
@ -1734,8 +1712,6 @@ void idRenderBackend::DBG_ShowShadowMapLODs()
GL_State( GLS_DEFAULT );
globalImages->BindNull();
renderProgManager.BindShader_Color();
GL_Cull( CT_TWO_SIDED );
@ -1831,7 +1807,6 @@ void idRenderBackend::DBG_ShowPortals()
// all portals are expressed in world coordinates
DBG_SimpleWorldSetup();
globalImages->BindNull();
renderProgManager.BindShader_Color();
GL_State( GLS_DEPTHFUNC_ALWAYS );
@ -2113,8 +2088,6 @@ void idRenderBackend::DBG_ShowDebugText()
// all lines are expressed in world coordinates
DBG_SimpleWorldSetup();
globalImages->BindNull();
width = r_debugLineWidth.GetInteger();
if( width < 1 )
{
@ -2246,8 +2219,6 @@ void idRenderBackend::DBG_ShowDebugLines()
renderProgManager.CommitUniforms();
// RB end
globalImages->BindNull();
width = r_debugLineWidth.GetInteger();
if( width < 1 )
{
@ -2387,8 +2358,6 @@ void idRenderBackend::DBG_ShowDebugPolygons()
renderProgManager.CommitUniforms();
// RB end
globalImages->BindNull();
if( r_debugPolygonFilled.GetBool() )
{
GL_State( GLS_POLYGON_OFFSET | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHMASK );

View file

@ -795,10 +795,6 @@ void idRenderBackend::FinishStageTexturing( const shaderStage_t* pStage, const d
if( pStage->texture.cinematic )
{
// unbind the extra bink textures
GL_SelectTexture( 1 );
globalImages->BindNull();
GL_SelectTexture( 2 );
globalImages->BindNull();
GL_SelectTexture( 0 );
}
@ -809,8 +805,6 @@ void idRenderBackend::FinishStageTexturing( const shaderStage_t* pStage, const d
if( bumpStage != NULL )
{
// per-pixel reflection mapping with bump mapping
GL_SelectTexture( 1 );
globalImages->BindNull();
GL_SelectTexture( 0 );
}
else
@ -2280,10 +2274,10 @@ void idRenderBackend::AmbientPass( const drawSurf_t* const* drawSurfs, int numDr
renderLog.CloseBlock();
renderLog.CloseMainBlock();
if( fillGbuffer )
{
GL_SelectTexture( 0 );
if( fillGbuffer )
{
// FIXME: this copies RGBA16F into _currentNormals if HDR is enabled
const idScreenRect& viewport = viewDef->viewport;
globalImages->currentNormalsImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
@ -2303,13 +2297,6 @@ void idRenderBackend::AmbientPass( const drawSurf_t* const* drawSurfs, int numDr
*/
}
// unbind texture units
for( int i = 0; i < 7; i++ )
{
GL_SelectTexture( i );
globalImages->BindNull();
}
renderProgManager.Unbind();
}
@ -2347,7 +2334,6 @@ void idRenderBackend::StencilShadowPass( const drawSurf_t* drawSurfs, const view
renderProgManager.BindShader_Shadow();
GL_SelectTexture( 0 );
globalImages->BindNull();
uint64 glState = 0;
@ -2870,7 +2856,6 @@ void idRenderBackend::ShadowMapPass( const drawSurf_t* drawSurfs, const viewLigh
renderProgManager.BindShader_Depth();
GL_SelectTexture( 0 );
globalImages->BindNull();
uint64 glState = 0;
@ -3619,11 +3604,6 @@ void idRenderBackend::DrawInteractions( const viewDef_t* _viewDef )
GL_State( GLS_DEFAULT );
// unbind texture units
for( int i = 0; i < 7; i++ )
{
GL_SelectTexture( i );
globalImages->BindNull();
}
GL_SelectTexture( 0 );
// reset depth bounds
@ -3665,9 +3645,6 @@ int idRenderBackend::DrawShaderPasses( const drawSurf_t* const* const drawSurfs,
renderLog.OpenBlock( "RB_DrawShaderPasses" );
GL_SelectTexture( 1 );
globalImages->BindNull();
GL_SelectTexture( 0 );
currentSpace = ( const viewEntity_t* )1; // using NULL makes /analyze think surf->space needs to be checked...
@ -3879,17 +3856,6 @@ int idRenderBackend::DrawShaderPasses( const drawSurf_t* const* const drawSurfs,
// draw it
DrawElementsWithCounters( surf );
// unbind texture units
for( int j = 0; j < newStage->numFragmentProgramImages; j++ )
{
idImage* image = newStage->fragmentProgramImages[j];
if( image != NULL )
{
GL_SelectTexture( j );
globalImages->BindNull();
}
}
// clear rpEnableSkinning if it was set
if( surf->jointCache && renderProgManager.ShaderHasOptionalSkinning() )
{
@ -4043,12 +4009,6 @@ int idRenderBackend::DrawShaderPasses( const drawSurf_t* const* const drawSurfs,
// disable stencil shadow test
GL_State( GLS_DEFAULT );
// unbind texture units
for( int i = 0; i < 7; i++ )
{
GL_SelectTexture( i );
globalImages->BindNull();
}
GL_SelectTexture( 0 );
renderLog.CloseBlock();
@ -4178,9 +4138,6 @@ void idRenderBackend::BlendLight( const drawSurf_t* drawSurfs, const drawSurf_t*
T_BlendLight( drawSurfs2, vLight );
}
GL_SelectTexture( 1 );
globalImages->BindNull();
GL_SelectTexture( 0 );
renderProgManager.Unbind();
@ -4358,9 +4315,6 @@ void idRenderBackend::FogPass( const drawSurf_t* drawSurfs, const drawSurf_t* d
GL_Cull( CT_FRONT_SIDED );
GL_SelectTexture( 1 );
globalImages->BindNull();
GL_SelectTexture( 0 );
renderProgManager.Unbind();
@ -4611,13 +4565,7 @@ void idRenderBackend::Tonemap( const viewDef_t* _viewDef )
// Draw
DrawElementsWithCounters( &unitSquareSurface );
// unbind heatmap
globalImages->BindNull();
// unbind _currentRender
GL_SelectTexture( 0 );
globalImages->BindNull();
renderProgManager.Unbind();
GL_State( GLS_DEFAULT );
@ -4741,9 +4689,6 @@ void idRenderBackend::Bloom( const viewDef_t* _viewDef )
DrawElementsWithCounters( &unitSquareSurface );
globalImages->BindNull();
Framebuffer::Unbind();
renderProgManager.Unbind();
GL_State( GLS_DEFAULT );
@ -5944,8 +5889,6 @@ void idRenderBackend::PostProcess( const void* data )
#endif
#if 1
globalImages->BindNull();
//GL_SelectTexture( 0 );
//globalImages->smaaBlendImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() );
@ -6003,15 +5946,7 @@ void idRenderBackend::PostProcess( const void* data )
}
#endif
GL_SelectTexture( 2 );
globalImages->BindNull();
GL_SelectTexture( 1 );
globalImages->BindNull();
GL_SelectTexture( 0 );
globalImages->BindNull();
renderProgManager.Unbind();
renderLog.CloseBlock();