From aa99a4d07c2ce6af31a44f6824b31d6665f4cd67 Mon Sep 17 00:00:00 2001 From: slipher Date: Tue, 7 Jan 2025 16:14:02 -0300 Subject: [PATCH 1/4] Migrate renderer "list" commands to new style Minor functional changes: - listModels: print MD3 per-frame data when any argument is given, instead of when the argument is "frames", since there was no usage message to discover that - listModels: use spaces instead of tabs since console doesn't display tabs - listAnimations: fix weird formatting of summary line --- src/engine/renderer/tr_animation.cpp | 30 +- src/engine/renderer/tr_fbo.cpp | 36 +- src/engine/renderer/tr_image.cpp | 608 +++++++++++++-------------- src/engine/renderer/tr_init.cpp | 35 +- src/engine/renderer/tr_local.h | 8 - src/engine/renderer/tr_model.cpp | 113 ++--- src/engine/renderer/tr_shader.cpp | 358 ++++++++-------- src/engine/renderer/tr_skin.cpp | 38 +- 8 files changed, 608 insertions(+), 618 deletions(-) diff --git a/src/engine/renderer/tr_animation.cpp b/src/engine/renderer/tr_animation.cpp index 491fc233ad..9e5fe88fd5 100644 --- a/src/engine/renderer/tr_animation.cpp +++ b/src/engine/renderer/tr_animation.cpp @@ -581,25 +581,27 @@ skelAnimation_t *R_GetAnimationByHandle( qhandle_t index ) return anim; } -/* -================ -R_ListAnimations_f -================ -*/ -void R_ListAnimations_f() +class ListAnimationsCmd : public Cmd::StaticCmd { - int i; - skelAnimation_t *anim; +public: + ListAnimationsCmd() : StaticCmd("listAnimations", "list model animations loaded in renderer") {} - for ( i = 0; i < tr.numAnimations; i++ ) + void Run( const Cmd::Args & ) const override { - anim = tr.animations[ i ]; + int i; + skelAnimation_t *anim; - Log::Notice("'%s'", anim->name ); - } + for ( i = 0; i < tr.numAnimations; i++ ) + { + anim = tr.animations[ i ]; - Log::Notice("%8i : Total animations", tr.numAnimations ); -} + Print( "'%s'", anim->name ); + } + + Print( "%i total animations", tr.numAnimations ); + } +}; +static ListAnimationsCmd listAnimationsCmdRegistration; /* ============= diff --git a/src/engine/renderer/tr_fbo.cpp b/src/engine/renderer/tr_fbo.cpp index b4f249c9bd..98beddeacb 100644 --- a/src/engine/renderer/tr_fbo.cpp +++ b/src/engine/renderer/tr_fbo.cpp @@ -591,25 +591,27 @@ void R_ShutdownFBOs() } } -/* -============ -R_ListFBOs_f -============ -*/ -void R_ListFBOs_f() +class ListFBOsCmd : public Cmd::StaticCmd { - int i; - FBO_t *fbo; - - Log::Notice(" size name" ); - Log::Notice("----------------------------------------------------------" ); +public: + ListFBOsCmd() : StaticCmd("listFBOs", "list renderer's OpenGL framebuffer objects") {} - for ( i = 0; i < tr.numFBOs; i++ ) + void Run( const Cmd::Args & ) const override { - fbo = tr.fbos[ i ]; + int i; + FBO_t *fbo; - Log::Notice(" %4i: %4i %4i %s", i, fbo->width, fbo->height, fbo->name ); - } + Print(" size name" ); + Print("----------------------------------------------------------" ); - Log::Notice(" %i FBOs", tr.numFBOs ); -} + for ( i = 0; i < tr.numFBOs; i++ ) + { + fbo = tr.fbos[ i ]; + + Print(" %4i: %4i %4i %s", i, fbo->width, fbo->height, fbo->name ); + } + + Print(" %i FBOs", tr.numFBOs ); + } +}; +static ListFBOsCmd listFBOsCmdRegistration; diff --git a/src/engine/renderer/tr_image.cpp b/src/engine/renderer/tr_image.cpp index 3d5730e486..b7d32839b5 100644 --- a/src/engine/renderer/tr_image.cpp +++ b/src/engine/renderer/tr_image.cpp @@ -137,349 +137,347 @@ void GL_TextureMode( const char *string ) } } -/* -=============== -R_ListImages_f -=============== -*/ -void R_ListImages_f() +class ListImagesCmd : public Cmd::StaticCmd { - static const std::unordered_map imageTypeName = { - { GL_TEXTURE_2D, "2D" }, - { GL_TEXTURE_3D, "3D" }, - { GL_TEXTURE_CUBE_MAP, "CUBE" }, - }; - - typedef std::pair nameSizePair; - static const std::unordered_map imageFormatNameSize = { - /* Generic format that does not have any specified actual format - and implementations can choose one of a few different ones - GL4.6 spec (https://registry.khronos.org/OpenGL/specs/gl/glspec46.core.pdf): - 8.5. TEXTURE IMAGE SPECIFICATION - "If internalformat is specified as a base internal format, the GL stores the resulting texture with - internal component resolutions of its own choosing, referred to as the effective internal format." - Use 4 bytes as an estimate: */ - { GL_RGBA, { "RGBA", 4 } }, - - { GL_RGB8, { "RGB8", 3 } }, - { GL_RGBA8, { "RGBA8", 4 } }, - { GL_RGB16, { "RGB16", 6 } }, - { GL_RGBA16, { "RGBA16", 8 } }, - { GL_RGB16F, { "RGB16F", 6 } }, - { GL_RGB32F, { "RGB32F", 12 } }, - { GL_RGBA16F, { "RGBA16F", 8 } }, - { GL_RGBA32F, { "RGBA32F", 16 } }, - { GL_RGBA32UI, { "RGBA32UI", 16 } }, - { GL_ALPHA16F_ARB, { "A16F", 2 } }, - { GL_ALPHA32F_ARB, { "A32F", 4 } }, - { GL_R16F, { "R16F", 2 } }, - { GL_R32F, { "R32F", 4 } }, - { GL_LUMINANCE_ALPHA16F_ARB, { "LA16F", 4 } }, - { GL_LUMINANCE_ALPHA32F_ARB, { "LA32F", 8 } }, - { GL_RG16F, { "RG16F", 4 } }, - { GL_RG32F, { "RG32F", 8 } }, - - // Compressed formats here use imageDataSize multiplier as blocksize +public: + ListImagesCmd() : StaticCmd("listImages", "list images loaded in renderer") {} + + void Run( const Cmd::Args &args ) const override + { + static const std::unordered_map imageTypeName = { + { GL_TEXTURE_2D, "2D" }, + { GL_TEXTURE_3D, "3D" }, + { GL_TEXTURE_CUBE_MAP, "CUBE" }, + }; + + typedef std::pair nameSizePair; + static const std::unordered_map imageFormatNameSize = { + /* Generic format that does not have any specified actual format + and implementations can choose one of a few different ones + GL4.6 spec (https://registry.khronos.org/OpenGL/specs/gl/glspec46.core.pdf): + 8.5. TEXTURE IMAGE SPECIFICATION + "If internalformat is specified as a base internal format, the GL stores the resulting texture with + internal component resolutions of its own choosing, referred to as the effective internal format." + Use 4 bytes as an estimate: */ + { GL_RGBA, { "RGBA", 4 } }, + + { GL_RGB8, { "RGB8", 3 } }, + { GL_RGBA8, { "RGBA8", 4 } }, + { GL_RGB16, { "RGB16", 6 } }, + { GL_RGBA16, { "RGBA16", 8 } }, + { GL_RGB16F, { "RGB16F", 6 } }, + { GL_RGB32F, { "RGB32F", 12 } }, + { GL_RGBA16F, { "RGBA16F", 8 } }, + { GL_RGBA32F, { "RGBA32F", 16 } }, + { GL_RGBA32UI, { "RGBA32UI", 16 } }, + { GL_ALPHA16F_ARB, { "A16F", 2 } }, + { GL_ALPHA32F_ARB, { "A32F", 4 } }, + { GL_R16F, { "R16F", 2 } }, + { GL_R32F, { "R32F", 4 } }, + { GL_LUMINANCE_ALPHA16F_ARB, { "LA16F", 4 } }, + { GL_LUMINANCE_ALPHA32F_ARB, { "LA32F", 8 } }, + { GL_RG16F, { "RG16F", 4 } }, + { GL_RG32F, { "RG32F", 8 } }, + + // Compressed formats here use imageDataSize multiplier as blocksize - /* Generic compressed format that does not have any specified actual format - and implementations can compress it in whatever way - GL4.6 spec (https://registry.khronos.org/OpenGL/specs/gl/glspec46.core.pdf): - 8.5. TEXTURE IMAGE SPECIFICATION - "Generic compressed internal formats are never used directly as the internal formats of texture images. - If internalformat is one of the six generic compressed internal formats, its value is replaced by the symbolic constant - for a specific compressed internal format of the GL’s choosing with the same base internal format." - Use 4x4 blocks with 8 bytes per block here as an estimate: */ - { GL_COMPRESSED_RGBA, { "RGBAC", 8 } }, - - /* https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_s3tc.txt - S3TC Compressed Texture Image Formats - "Compressed texture images stored using the S3TC compressed image formats - are represented as a collection of 4x4 texel blocks, where each block - contains 64 or 128 bits of texel data. The image is encoded as a normal - 2D raster image in which each 4x4 block is treated as a single pixel. If - an S3TC image has a width or height that is not a multiple of four, the - data corresponding to texels outside the image are irrelevant and - undefined. - - When an S3TC image with a width of w, height of h, and block size of - blocksize (8 or 16 bytes) is decoded, the corresponding image size (in - bytes) is: ceil( w / 4 ) * ceil( h / 4 ) * blocksize." - - All of the following have blocksize of 8 bytes: */ - { GL_COMPRESSED_RGB_S3TC_DXT1_EXT, { "DXT1", 8 } }, - { GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, { "DXT1a", 8 } }, - { GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, { "DXT3", 8 } }, - { GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, { "DXT5", 8 } }, - - /* GL4.6 spec: Appendix D Compressed Texture Image Formats - D.1 RGTC Compressed Texture Image Formats (https://registry.khronos.org/OpenGL/specs/gl/glspec46.core.pdf) - Khronos Data Format Specification v1.1 rev 9 - 14. RGTC Compressed Texture Image Formats (https://registry.khronos.org/DataFormat/specs/1.1/dataformat.1.1.html#RGTC) - "Compressed texture images stored using the RGTC compressed image encodings are represented as a collection of 4×4 texel blocks, - where each block contains 64 or 128 bits of texel data. The image is encoded as a normal 2D raster image in which each 4×4 block - is treated as a single pixel. If an RGTC image has a width or height that is not a multiple of four, - the data corresponding to texels outside the image are irrelevant and undefined. + /* Generic compressed format that does not have any specified actual format + and implementations can compress it in whatever way + GL4.6 spec (https://registry.khronos.org/OpenGL/specs/gl/glspec46.core.pdf): + 8.5. TEXTURE IMAGE SPECIFICATION + "Generic compressed internal formats are never used directly as the internal formats of texture images. + If internalformat is one of the six generic compressed internal formats, its value is replaced by the symbolic constant + for a specific compressed internal format of the GL’s choosing with the same base internal format." + Use 4x4 blocks with 8 bytes per block here as an estimate: */ + { GL_COMPRESSED_RGBA, { "RGBAC", 8 } }, + + /* https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_s3tc.txt + S3TC Compressed Texture Image Formats + "Compressed texture images stored using the S3TC compressed image formats + are represented as a collection of 4x4 texel blocks, where each block + contains 64 or 128 bits of texel data. The image is encoded as a normal + 2D raster image in which each 4x4 block is treated as a single pixel. If + an S3TC image has a width or height that is not a multiple of four, the + data corresponding to texels outside the image are irrelevant and + undefined. + + When an S3TC image with a width of w, height of h, and block size of + blocksize (8 or 16 bytes) is decoded, the corresponding image size (in + bytes) is: ceil( w / 4 ) * ceil( h / 4 ) * blocksize." + + All of the following have blocksize of 8 bytes: */ + { GL_COMPRESSED_RGB_S3TC_DXT1_EXT, { "DXT1", 8 } }, + { GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, { "DXT1a", 8 } }, + { GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, { "DXT3", 8 } }, + { GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, { "DXT5", 8 } }, + + /* GL4.6 spec: Appendix D Compressed Texture Image Formats + D.1 RGTC Compressed Texture Image Formats (https://registry.khronos.org/OpenGL/specs/gl/glspec46.core.pdf) + Khronos Data Format Specification v1.1 rev 9 + 14. RGTC Compressed Texture Image Formats (https://registry.khronos.org/DataFormat/specs/1.1/dataformat.1.1.html#RGTC) + "Compressed texture images stored using the RGTC compressed image encodings are represented as a collection of 4×4 texel blocks, + where each block contains 64 or 128 bits of texel data. The image is encoded as a normal 2D raster image in which each 4×4 block + is treated as a single pixel. If an RGTC image has a width or height that is not a multiple of four, + the data corresponding to texels outside the image are irrelevant and undefined. - When an RGTC image with a width of w, height of h, and block size of blocksize (8 or 16 bytes) is decoded, - the corresponding image size (in bytes) is: ceil( w / 4 ) * ceil( h / 4 ) * blocksize." - - All of the following use blocksize of 8 bytes: */ - { GL_COMPRESSED_RED_RGTC1, { "RGTC1r", 8 } }, - { GL_COMPRESSED_SIGNED_RED_RGTC1, { "RGTC1Sr", 8 } }, - { GL_COMPRESSED_RG_RGTC2, { "RGTC2rg", 8 } }, - { GL_COMPRESSED_SIGNED_RG_RGTC2, { "RGTC2Srg", 8 } }, - - // These usually still use a 32-bit format internally - { GL_DEPTH_COMPONENT16, { "D16", 2 } }, - { GL_DEPTH_COMPONENT24, { "D24", 3 } }, - { GL_DEPTH_COMPONENT32, { "D32", 4 } }, - { GL_DEPTH24_STENCIL8, { "D24S8", 4 } }, - }; - - static const std::unordered_map wrapTypeName = { - { wrapTypeEnum_t::WT_REPEAT, "rept" }, - { wrapTypeEnum_t::WT_CLAMP, "clmp" }, - { wrapTypeEnum_t::WT_EDGE_CLAMP, "eclmp" }, - { wrapTypeEnum_t::WT_ZERO_CLAMP, "0clmp" }, - { wrapTypeEnum_t::WT_ONE_CLAMP, "1clmp" }, - { wrapTypeEnum_t::WT_ALPHA_ZERO_CLAMP, "a0clmp" }, - }; - - const char *yesno[] = { "no", "yes" }; - const char *filter = ri.Cmd_Argc() > 1 ? ri.Cmd_Argv(1) : nullptr; - - // Header names - std::string num = "num"; - std::string width = "width"; - std::string height = "height"; - std::string layers = "layers"; - std::string mm = "mm"; - std::string type = "type"; - std::string format = "format"; - std::string twrap = "wrap.t"; - std::string swrap = "wrap.s"; - std::string name = "name"; - - // Number sizes - size_t numLen = 5; - size_t widthLen = 5; - size_t heightLen = 5; - size_t layersLen = 5; - size_t mmLen = 3; - size_t typeLen = 4; - size_t formatLen = 4; - size_t twrapLen = 4; - size_t swrapLen = 4; - - // Header number sizes - numLen = std::max( numLen, num.length() ); - widthLen = std::max( widthLen, width.length() ); - heightLen = std::max( heightLen, height.length() ); - layersLen = std::max( layersLen, layers.length() ); - mmLen = std::max( mmLen, mm.length() ); - typeLen = std::max( typeLen, type.length() ); - formatLen = std::max( formatLen, format.length() ); - twrapLen = std::max( twrapLen, twrap.length() ); - swrapLen = std::max( swrapLen, swrap.length() ); - - // Value sizes - for ( const auto& kv : imageTypeName ) - { - typeLen = std::max( typeLen, kv.second.length() ); - } + When an RGTC image with a width of w, height of h, and block size of blocksize (8 or 16 bytes) is decoded, + the corresponding image size (in bytes) is: ceil( w / 4 ) * ceil( h / 4 ) * blocksize." + + All of the following use blocksize of 8 bytes: */ + { GL_COMPRESSED_RED_RGTC1, { "RGTC1r", 8 } }, + { GL_COMPRESSED_SIGNED_RED_RGTC1, { "RGTC1Sr", 8 } }, + { GL_COMPRESSED_RG_RGTC2, { "RGTC2rg", 8 } }, + { GL_COMPRESSED_SIGNED_RG_RGTC2, { "RGTC2Srg", 8 } }, + + // These usually still use a 32-bit format internally + { GL_DEPTH_COMPONENT16, { "D16", 2 } }, + { GL_DEPTH_COMPONENT24, { "D24", 3 } }, + { GL_DEPTH_COMPONENT32, { "D32", 4 } }, + { GL_DEPTH24_STENCIL8, { "D24S8", 4 } }, + }; + + static const std::unordered_map wrapTypeName = { + { wrapTypeEnum_t::WT_REPEAT, "rept" }, + { wrapTypeEnum_t::WT_CLAMP, "clmp" }, + { wrapTypeEnum_t::WT_EDGE_CLAMP, "eclmp" }, + { wrapTypeEnum_t::WT_ZERO_CLAMP, "0clmp" }, + { wrapTypeEnum_t::WT_ONE_CLAMP, "1clmp" }, + { wrapTypeEnum_t::WT_ALPHA_ZERO_CLAMP, "a0clmp" }, + }; + + const char *yesno[] = { "no", "yes" }; + const char *filter = args.Argc() > 1 ? args.Argv( 1 ).c_str() : nullptr; + + // Header names + std::string num = "num"; + std::string width = "width"; + std::string height = "height"; + std::string layers = "layers"; + std::string mm = "mm"; + std::string type = "type"; + std::string format = "format"; + std::string twrap = "wrap.t"; + std::string swrap = "wrap.s"; + std::string name = "name"; + + // Number sizes + size_t numLen = 5; + size_t widthLen = 5; + size_t heightLen = 5; + size_t layersLen = 5; + size_t mmLen = 3; + size_t typeLen = 4; + size_t formatLen = 4; + size_t twrapLen = 4; + size_t swrapLen = 4; + + // Header number sizes + numLen = std::max( numLen, num.length() ); + widthLen = std::max( widthLen, width.length() ); + heightLen = std::max( heightLen, height.length() ); + layersLen = std::max( layersLen, layers.length() ); + mmLen = std::max( mmLen, mm.length() ); + typeLen = std::max( typeLen, type.length() ); + formatLen = std::max( formatLen, format.length() ); + twrapLen = std::max( twrapLen, twrap.length() ); + swrapLen = std::max( swrapLen, swrap.length() ); + + // Value sizes + for ( const auto& kv : imageTypeName ) + { + typeLen = std::max( typeLen, kv.second.length() ); + } - for ( const auto& kv : imageFormatNameSize ) - { - formatLen = std::max( formatLen, kv.second.first.length() ); - } + for ( const auto& kv : imageFormatNameSize ) + { + formatLen = std::max( formatLen, kv.second.first.length() ); + } - for ( const auto& kv: wrapTypeName ) - { - // 2 for the "t." and "s." prefix length. - twrapLen = std::max( twrapLen, 2 + kv.second.length() ); - swrapLen = std::max( swrapLen, 2 + kv.second.length() ); - } + for ( const auto& kv: wrapTypeName ) + { + // 2 for the "t." and "s." prefix length. + twrapLen = std::max( twrapLen, 2 + kv.second.length() ); + swrapLen = std::max( swrapLen, 2 + kv.second.length() ); + } - std::string separator = " "; - std::stringstream lineStream; + std::string separator = " "; + std::stringstream lineStream; - // Print header - lineStream << std::left; - lineStream << std::setw(numLen) << num << separator; - lineStream << std::right; - lineStream << std::setw(widthLen) << width << separator; - lineStream << std::setw(heightLen) << height << separator; - lineStream << std::setw(layersLen) << layers << separator; - lineStream << std::left; - lineStream << std::setw(mmLen) << mm << separator; - lineStream << std::setw(typeLen) << type << separator; - lineStream << std::setw(formatLen) << format << separator; - lineStream << std::setw(twrapLen) << twrap << separator; - lineStream << std::setw(swrapLen) << swrap << separator; - lineStream << name; + // Print header + lineStream << std::left; + lineStream << std::setw(numLen) << num << separator; + lineStream << std::right; + lineStream << std::setw(widthLen) << width << separator; + lineStream << std::setw(heightLen) << height << separator; + lineStream << std::setw(layersLen) << layers << separator; + lineStream << std::left; + lineStream << std::setw(mmLen) << mm << separator; + lineStream << std::setw(typeLen) << type << separator; + lineStream << std::setw(formatLen) << format << separator; + lineStream << std::setw(twrapLen) << twrap << separator; + lineStream << std::setw(swrapLen) << swrap << separator; + lineStream << name; - std::string lineSeparator( lineStream.str().length(), '-' ); + std::string lineSeparator( lineStream.str().length(), '-' ); - Log::CommandInteractionMessage( lineSeparator ); - Log::CommandInteractionMessage( lineStream.str() ); - Log::CommandInteractionMessage( lineSeparator ); + Print( lineSeparator ); + Print( lineStream.str() ); + Print( lineSeparator ); - int texels = 0; - int dataSize = 0; + int texels = 0; + int dataSize = 0; - for ( size_t i = 0; i < tr.images.size(); i++ ) - { - const image_t *image = tr.images[ i ]; - if ( filter && !Com_Filter( filter, image->name, true ) ) + for ( size_t i = 0; i < tr.images.size(); i++ ) { - continue; - } + const image_t *image = tr.images[ i ]; + if ( filter && !Com_Filter( filter, image->name, true ) ) + { + continue; + } - mm = yesno[ image->filterType == filterType_t::FT_DEFAULT ]; + mm = yesno[ image->filterType == filterType_t::FT_DEFAULT ]; - if ( !imageTypeName.count( image->type ) ) - { - Log::Debug( "Undocumented image type %i (%X) for image %s", - image->type, image->type, image->name ); + if ( !imageTypeName.count( image->type ) ) + { + Log::Debug( "Undocumented image type %i (%X) for image %s", + image->type, image->type, image->name ); - type = Str::Format( "0x%4X", image->type ); - } - else - { - type = imageTypeName.at( image->type ); - } + type = Str::Format( "0x%4X", image->type ); + } + else + { + type = imageTypeName.at( image->type ); + } - int imageDataSize = 0; - texels += imageDataSize; + int imageDataSize = 0; + texels += imageDataSize; - if ( !imageFormatNameSize.count( image->internalFormat ) ) - { - Log::Debug( "Undocumented image format %i (%X) for image %s", - image->internalFormat, image->internalFormat, image->name ); + if ( !imageFormatNameSize.count( image->internalFormat ) ) + { + Log::Debug( "Undocumented image format %i (%X) for image %s", + image->internalFormat, image->internalFormat, image->name ); - format = Str::Format( "0x%04X", image->internalFormat); - imageDataSize *= 4; - } - else - { - switch ( image->internalFormat ) { - // Compressed formats encode blocks of 4x4 texels - case GL_COMPRESSED_RGBA: - case GL_COMPRESSED_RED_RGTC1: - case GL_COMPRESSED_SIGNED_RED_RGTC1: - case GL_COMPRESSED_RG_RGTC2: - case GL_COMPRESSED_SIGNED_RG_RGTC2: - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - { - format = imageFormatNameSize.at( image->internalFormat ).first; + format = Str::Format( "0x%04X", image->internalFormat); + imageDataSize *= 4; + } + else + { + switch ( image->internalFormat ) { + // Compressed formats encode blocks of 4x4 texels + case GL_COMPRESSED_RGBA: + case GL_COMPRESSED_RED_RGTC1: + case GL_COMPRESSED_SIGNED_RED_RGTC1: + case GL_COMPRESSED_RG_RGTC2: + case GL_COMPRESSED_SIGNED_RG_RGTC2: + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + { + format = imageFormatNameSize.at( image->internalFormat ).first; - uint16_t imageWidth = image->uploadWidth; - uint16_t imageHeight = image->uploadHeight; - uint16_t imageLayers = image->numLayers; + uint16_t imageWidth = image->uploadWidth; + uint16_t imageHeight = image->uploadHeight; + uint16_t imageLayers = image->numLayers; - int numMips = 1; - if ( image->filterType == filterType_t::FT_DEFAULT ) { - numMips = log2f( std::max( std::max( imageWidth, imageHeight ), imageLayers ) ) + 1; - } + int numMips = 1; + if ( image->filterType == filterType_t::FT_DEFAULT ) { + numMips = log2f( std::max( std::max( imageWidth, imageHeight ), imageLayers ) ) + 1; + } - for ( int j = 0; j < numMips; j++ ) { - imageDataSize += ceil( imageWidth / 4.0 ) * ceil( imageHeight / 4.0 ) * imageLayers; - imageWidth >>= imageWidth > 1 ? 1 : 0; - imageHeight >>= imageHeight > 1 ? 1 : 0; - imageLayers >>= imageLayers > 1 ? 1 : 0; - } + for ( int j = 0; j < numMips; j++ ) { + imageDataSize += ceil( imageWidth / 4.0 ) * ceil( imageHeight / 4.0 ) * imageLayers; + imageWidth >>= imageWidth > 1 ? 1 : 0; + imageHeight >>= imageHeight > 1 ? 1 : 0; + imageLayers >>= imageLayers > 1 ? 1 : 0; + } - imageDataSize *= imageFormatNameSize.at( image->internalFormat ).second; - break; - } - default: - { - format = imageFormatNameSize.at( image->internalFormat ).first; + imageDataSize *= imageFormatNameSize.at( image->internalFormat ).second; + break; + } + default: + { + format = imageFormatNameSize.at( image->internalFormat ).first; - uint16_t imageWidth = image->uploadWidth; - uint16_t imageHeight = image->uploadHeight; - uint16_t imageLayers = image->numLayers; + uint16_t imageWidth = image->uploadWidth; + uint16_t imageHeight = image->uploadHeight; + uint16_t imageLayers = image->numLayers; - int numMips = 1; - if ( image->filterType == filterType_t::FT_DEFAULT ) { - numMips = log2f( std::max( std::max( imageWidth, imageHeight ), imageLayers ) ) + 1; - } + int numMips = 1; + if ( image->filterType == filterType_t::FT_DEFAULT ) { + numMips = log2f( std::max( std::max( imageWidth, imageHeight ), imageLayers ) ) + 1; + } - for ( int j = 0; j < numMips; j++ ) { - imageDataSize += imageWidth * imageHeight * imageLayers; - imageWidth >>= imageWidth > 1 ? 1 : 0; - imageHeight >>= imageHeight > 1 ? 1 : 0; - imageLayers >>= imageLayers > 1 ? 1 : 0; - } + for ( int j = 0; j < numMips; j++ ) { + imageDataSize += imageWidth * imageHeight * imageLayers; + imageWidth >>= imageWidth > 1 ? 1 : 0; + imageHeight >>= imageHeight > 1 ? 1 : 0; + imageLayers >>= imageLayers > 1 ? 1 : 0; + } - imageDataSize *= imageFormatNameSize.at( image->internalFormat ).second; - break; + imageDataSize *= imageFormatNameSize.at( image->internalFormat ).second; + break; + } } } - } - - if ( !wrapTypeName.count( image->wrapType.t ) ) - { - Log::Debug( "Undocumented wrapType.t %i for image %s", - Util::ordinal(image->wrapType.t), image->name ); - twrap = Str::Format( "t.%4i", Util::ordinal(image->wrapType.t) ); - } - else - { - twrap = "t." + wrapTypeName.at( image->wrapType.t ); - } + if ( !wrapTypeName.count( image->wrapType.t ) ) + { + Log::Debug( "Undocumented wrapType.t %i for image %s", + Util::ordinal(image->wrapType.t), image->name ); - if ( !wrapTypeName.count( image->wrapType.s ) ) - { - Log::Debug( "Undocumented wrapType.s %i for image %s", - Util::ordinal(image->wrapType.s), image->name ); + twrap = Str::Format( "t.%4i", Util::ordinal(image->wrapType.t) ); + } + else + { + twrap = "t." + wrapTypeName.at( image->wrapType.t ); + } - swrap = Str::Format( "s.%4i", Util::ordinal(image->wrapType.s) ); - } - else - { - swrap = "s." + wrapTypeName.at( image->wrapType.s ); - } + if ( !wrapTypeName.count( image->wrapType.s ) ) + { + Log::Debug( "Undocumented wrapType.s %i for image %s", + Util::ordinal(image->wrapType.s), image->name ); - name = image->name; + swrap = Str::Format( "s.%4i", Util::ordinal(image->wrapType.s) ); + } + else + { + swrap = "s." + wrapTypeName.at( image->wrapType.s ); + } - lineStream.clear(); - lineStream.str(""); + name = image->name; - lineStream << std::left; - lineStream << std::setw(numLen) << i << separator; - lineStream << std::right; - lineStream << std::setw(widthLen) << image->uploadWidth << separator; - lineStream << std::setw(heightLen) << image->uploadHeight << separator; - lineStream << std::setw(layersLen) << image->numLayers << separator; - lineStream << std::left; - lineStream << std::setw(mmLen) << mm << separator; - lineStream << std::setw(typeLen) << type << separator; - lineStream << std::setw(formatLen) << format << separator; - lineStream << std::setw(twrapLen) << twrap << separator; - lineStream << std::setw(swrapLen) << swrap << separator; - lineStream << name; + lineStream.clear(); + lineStream.str(""); - Log::CommandInteractionMessage( lineStream.str() ); + lineStream << std::left; + lineStream << std::setw(numLen) << i << separator; + lineStream << std::right; + lineStream << std::setw(widthLen) << image->uploadWidth << separator; + lineStream << std::setw(heightLen) << image->uploadHeight << separator; + lineStream << std::setw(layersLen) << image->numLayers << separator; + lineStream << std::left; + lineStream << std::setw(mmLen) << mm << separator; + lineStream << std::setw(typeLen) << type << separator; + lineStream << std::setw(formatLen) << format << separator; + lineStream << std::setw(twrapLen) << twrap << separator; + lineStream << std::setw(swrapLen) << swrap << separator; + lineStream << name; - dataSize += imageDataSize; - } + Print( lineStream.str() ); - std::string summary1 = Str::Format( "%i total texels (not including mipmaps)", texels ); - std::string summary2 = Str::Format( "%d.%02d MB total image memory (estimated)", - dataSize / ( 1024 * 1024 ), ( dataSize % ( 1024 * 1024 ) ) * 100 / ( 1024 * 1024 ) ); - std::string summary3 = Str::Format( "%i total images", tr.images.size() ); + dataSize += imageDataSize; + } - Log::CommandInteractionMessage( lineSeparator ); - Log::CommandInteractionMessage( summary1 ); - Log::CommandInteractionMessage( summary2 ); - Log::CommandInteractionMessage( summary3 ); - Log::CommandInteractionMessage( lineSeparator ); -} + Print( lineSeparator ); + Print( "%i total texels (not including mipmaps)", texels ); + Print( "%d.%02d MB total image memory (estimated)", + dataSize / ( 1024 * 1024 ), ( dataSize % ( 1024 * 1024 ) ) * 100 / ( 1024 * 1024 ) ); + Print( "%i total images", tr.images.size() ); + Print( lineSeparator ); + } +}; +static ListImagesCmd listImagesCmdRegistration; //======================================================================= diff --git a/src/engine/renderer/tr_init.cpp b/src/engine/renderer/tr_init.cpp index 73b1f619b6..080c4ada28 100644 --- a/src/engine/renderer/tr_init.cpp +++ b/src/engine/renderer/tr_init.cpp @@ -518,18 +518,21 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA return true; } - /* - ** R_ListModes_f - */ - static void R_ListModes_f() + class ListModesCmd : public Cmd::StaticCmd { - int i; - - for ( i = 0; i < s_numVidModes; i++ ) + public: + ListModesCmd() : StaticCmd("listModes", "list suggested screen/window dimensions") {} + void Run( const Cmd::Args& ) const override { - Log::Notice("Mode %-2d: %s", i, r_vidModes[ i ].description ); + int i; + + for ( i = 0; i < s_numVidModes; i++ ) + { + Print("Mode %-2d: %s", i, r_vidModes[ i ].description ); + } } - } + }; + static ListModesCmd listModesCmdRegistration; /* ================== @@ -1350,14 +1353,7 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p Cvar::Latch( r_profilerRenderSubGroups ); // make sure all the commands added here are also removed in R_Shutdown - ri.Cmd_AddCommand( "listImages", R_ListImages_f ); - ri.Cmd_AddCommand( "listShaders", R_ListShaders_f ); ri.Cmd_AddCommand( "shaderexp", R_ShaderExp_f ); - ri.Cmd_AddCommand( "listSkins", R_ListSkins_f ); - ri.Cmd_AddCommand( "listModels", R_ListModels_f ); - ri.Cmd_AddCommand( "listModes", R_ListModes_f ); - ri.Cmd_AddCommand( "listAnimations", R_ListAnimations_f ); - ri.Cmd_AddCommand( "listFBOs", R_ListFBOs_f ); ri.Cmd_AddCommand( "gfxinfo", GfxInfo_f ); ri.Cmd_AddCommand( "buildcubemaps", R_BuildCubeMaps ); @@ -1534,16 +1530,9 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p { Log::Debug("RE_Shutdown( destroyWindow = %i )", destroyWindow ); - ri.Cmd_RemoveCommand( "listModels" ); - ri.Cmd_RemoveCommand( "listImages" ); - ri.Cmd_RemoveCommand( "listShaders" ); ri.Cmd_RemoveCommand( "shaderexp" ); - ri.Cmd_RemoveCommand( "listSkins" ); ri.Cmd_RemoveCommand( "gfxinfo" ); - ri.Cmd_RemoveCommand( "listModes" ); ri.Cmd_RemoveCommand( "shaderstate" ); - ri.Cmd_RemoveCommand( "listAnimations" ); - ri.Cmd_RemoveCommand( "listFBOs" ); ri.Cmd_RemoveCommand( "generatemtr" ); ri.Cmd_RemoveCommand( "buildcubemaps" ); diff --git a/src/engine/renderer/tr_local.h b/src/engine/renderer/tr_local.h index b44fc3e0cc..a81e8249fa 100644 --- a/src/engine/renderer/tr_local.h +++ b/src/engine/renderer/tr_local.h @@ -2324,8 +2324,6 @@ enum class shaderProfilerRenderSubGroupsMode { void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ); - void R_ListModels_f(); - //==================================================== extern refimport_t ri; @@ -3252,9 +3250,6 @@ inline bool checkGLErrors() bool R_GetModeInfo( int *width, int *height, int mode ); - void R_ListImages_f(); - void R_ListSkins_f(); - // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=516 const void *RB_TakeScreenshotCmd( const void *data ); @@ -3308,7 +3303,6 @@ inline bool checkGLErrors() shader_t *R_FindShaderByName( const char *name ); const char *RE_GetShaderNameFromHandle( qhandle_t shader ); void R_InitShaders(); - void R_ListShaders_f(); void R_ShaderExp_f(); void R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset ); @@ -3650,7 +3644,6 @@ inline bool checkGLErrors() void R_InitFBOs(); void R_ShutdownFBOs(); - void R_ListFBOs_f(); /* ============================================================ @@ -3719,7 +3712,6 @@ inline bool checkGLErrors() qhandle_t RE_RegisterAnimationIQM( const char *name, IQAnim_t *data ); skelAnimation_t *R_GetAnimationByHandle( qhandle_t hAnim ); - void R_ListAnimations_f(); void R_AddMD5Surfaces( trRefEntity_t *ent ); void R_AddMD5Interactions( trRefEntity_t *ent, trRefLight_t *light, interactionType_t iaType ); diff --git a/src/engine/renderer/tr_model.cpp b/src/engine/renderer/tr_model.cpp index 655341be54..a8ce4a733a 100644 --- a/src/engine/renderer/tr_model.cpp +++ b/src/engine/renderer/tr_model.cpp @@ -305,83 +305,86 @@ void R_ModelInit() mod->type = modtype_t::MOD_BAD; } -/* -================ -R_ListModels_f -================ -*/ -void R_ListModels_f() +// shows MD3 per-frame info if there is an argument +class ListModelsCmd : public Cmd::StaticCmd { - int i, j, k; - model_t *mod; - int total; - int totalDataSize; - bool showFrames; +public: + ListModelsCmd() : StaticCmd("listModels", "list loaded 3D models") {} - showFrames = !strcmp( ri.Cmd_Argv( 1 ), "frames" ); + void Run( const Cmd::Args &args ) const override + { + int i, j, k; + model_t *mod; + int total; + int totalDataSize; + bool showFrames; - total = 0; - totalDataSize = 0; + showFrames = args.Argc() > 1; - for ( i = 1; i < tr.numModels; i++ ) - { - mod = tr.models[ i ]; + total = 0; + totalDataSize = 0; - if ( mod->type == modtype_t::MOD_MESH ) + for ( i = 1; i < tr.numModels; i++ ) { - for ( j = 0; j < MD3_MAX_LODS; j++ ) + mod = tr.models[ i ]; + + if ( mod->type == modtype_t::MOD_MESH ) { - if ( mod->mdv[ j ] && ( j == 0 || mod->mdv[ j ] != mod->mdv[ j - 1 ] ) ) + for ( j = 0; j < MD3_MAX_LODS; j++ ) { - mdvModel_t *mdvModel; - mdvSurface_t *mdvSurface; - mdvTagName_t *mdvTagName; - - mdvModel = mod->mdv[ j ]; + if ( mod->mdv[ j ] && ( j == 0 || mod->mdv[ j ] != mod->mdv[ j - 1 ] ) ) + { + mdvModel_t *mdvModel; + mdvSurface_t *mdvSurface; + mdvTagName_t *mdvTagName; - total++; - Log::Notice("%d.%02d MB '%s' LOD = %i", mod->dataSize / ( 1024 * 1024 ), - ( mod->dataSize % ( 1024 * 1024 ) ) * 100 / ( 1024 * 1024 ), - mod->name, j ); + mdvModel = mod->mdv[ j ]; - if ( showFrames && mdvModel->numFrames > 1 ) - { - Log::Notice("\tnumSurfaces = %i", mdvModel->numSurfaces ); - Log::Notice("\tnumFrames = %i", mdvModel->numFrames ); + total++; + Print( "%d.%02d MB '%s' LOD = %i", mod->dataSize / ( 1024 * 1024 ), + ( mod->dataSize % ( 1024 * 1024 ) ) * 100 / ( 1024 * 1024 ), + mod->name, j ); - for ( k = 0, mdvSurface = mdvModel->surfaces; k < mdvModel->numSurfaces; k++, mdvSurface++ ) + if ( showFrames && mdvModel->numFrames > 1 ) { - Log::Notice("\t\tmesh = '%s'", mdvSurface->name ); - Log::Notice("\t\t\tnumVertexes = %i", mdvSurface->numVerts ); - Log::Notice("\t\t\tnumTriangles = %i", mdvSurface->numTriangles ); + Print(" numSurfaces = %i", mdvModel->numSurfaces ); + Print(" numFrames = %i", mdvModel->numFrames ); + + for ( k = 0, mdvSurface = mdvModel->surfaces; k < mdvModel->numSurfaces; k++, mdvSurface++ ) + { + Print(" mesh = '%s'", mdvSurface->name ); + Print(" numVertexes = %i", mdvSurface->numVerts ); + Print(" numTriangles = %i", mdvSurface->numTriangles ); + } } - } - Log::Notice("\t\tnumTags = %i", mdvModel->numTags ); + Print(" numTags = %i", mdvModel->numTags ); - for ( k = 0, mdvTagName = mdvModel->tagNames; k < mdvModel->numTags; k++, mdvTagName++ ) - { - Log::Notice("\t\t\ttagName = '%s'", mdvTagName->name ); + for ( k = 0, mdvTagName = mdvModel->tagNames; k < mdvModel->numTags; k++, mdvTagName++ ) + { + Print(" tagName = '%s'", mdvTagName->name ); + } } } } - } - else - { - Log::Notice("%d.%02d MB '%s'", mod->dataSize / ( 1024 * 1024 ), - ( mod->dataSize % ( 1024 * 1024 ) ) * 100 / ( 1024 * 1024 ), - mod->name ); + else + { + Print( "%d.%02d MB '%s'", mod->dataSize / ( 1024 * 1024 ), + ( mod->dataSize % ( 1024 * 1024 ) ) * 100 / ( 1024 * 1024 ), + mod->name ); + + total++; + } - total++; + totalDataSize += mod->dataSize; } - totalDataSize += mod->dataSize; + Print(" %d.%02d MB total model memory", totalDataSize / ( 1024 * 1024 ), + ( totalDataSize % ( 1024 * 1024 ) ) * 100 / ( 1024 * 1024 ) ); + Print(" %i total models", total ); } - - Log::Notice(" %d.%02d MB total model memory", totalDataSize / ( 1024 * 1024 ), - ( totalDataSize % ( 1024 * 1024 ) ) * 100 / ( 1024 * 1024 ) ); - Log::Notice(" %i total models", total ); -} +}; +static ListModelsCmd listModelsCmdRegistration; //============================================================================= diff --git a/src/engine/renderer/tr_shader.cpp b/src/engine/renderer/tr_shader.cpp index e6b91c1960..57b6767e09 100644 --- a/src/engine/renderer/tr_shader.cpp +++ b/src/engine/renderer/tr_shader.cpp @@ -6634,224 +6634,226 @@ shader_t *R_GetShaderByHandle( qhandle_t hShader ) /* =============== -R_ListShaders_f - Dump information on all valid shaders to the console A second parameter will cause it to print in sorted order =============== */ -void R_ListShaders_f() +class ListShadersCmd : public Cmd::StaticCmd { - static const std::unordered_map shaderTypeName = { - { shaderType_t::SHADER_2D, "2D" }, - { shaderType_t::SHADER_3D_DYNAMIC, "3D_DYNAMIC" }, - { shaderType_t::SHADER_3D_STATIC, "3D_STATIC" }, - { shaderType_t::SHADER_LIGHT, "LIGHT" }, - }; - - static const std::unordered_map shaderSortName = { - { shaderSort_t::SS_BAD, "BAD" }, - { shaderSort_t::SS_PORTAL, "PORTAL" }, - { shaderSort_t::SS_DEPTH, "DEPTH" }, - { shaderSort_t::SS_ENVIRONMENT_FOG, "ENV_FOG" }, - { shaderSort_t::SS_ENVIRONMENT_NOFOG, "ENV_NOFOG" }, - { shaderSort_t::SS_OPAQUE, "OPAQUE" }, - { shaderSort_t::SS_DECAL, "DECAL" }, - { shaderSort_t::SS_SEE_THROUGH, "SEE_THROUGH" }, - { shaderSort_t::SS_BANNER, "BANNER" }, - { shaderSort_t::SS_FOG, "FOG" }, - { shaderSort_t::SS_UNDERWATER, "UNDERWATER" }, - { shaderSort_t::SS_WATER, "WATER" }, - { shaderSort_t::SS_FAR, "FAR" }, - { shaderSort_t::SS_MEDIUM, "MEDIUM" }, - { shaderSort_t::SS_CLOSE, "CLOSE" }, - { shaderSort_t::SS_BLEND0, "BLEND0" }, - { shaderSort_t::SS_BLEND1, "BLEND1" }, - { shaderSort_t::SS_BLEND2, "BLEND2" }, - { shaderSort_t::SS_BLEND3, "BLEND3" }, - { shaderSort_t::SS_BLEND6, "BLEND6" }, - { shaderSort_t::SS_ALMOST_NEAREST, "ALMOST_NEAREST" }, - { shaderSort_t::SS_NEAREST, "NEAREST" }, - { shaderSort_t::SS_POST_PROCESS, "POST_PROCESS" }, - }; - - static const std::unordered_map stageTypeName = { - { stageType_t::ST_COLORMAP, "COLORMAP" }, - { stageType_t::ST_GLOWMAP, "GLOWMAP" }, - { stageType_t::ST_DIFFUSEMAP, "DIFFUSEMAP" }, - { stageType_t::ST_NORMALMAP, "NORMALMAP" }, - { stageType_t::ST_HEIGHTMAP, "HEIGHTMAP" }, - { stageType_t::ST_PHYSICALMAP, "PHYSICALMAP" }, - { stageType_t::ST_SPECULARMAP, "SPECULARMAP" }, - { stageType_t::ST_REFLECTIONMAP, "REFLECTIONMAP" }, - { stageType_t::ST_REFRACTIONMAP, "REFRACTIONMAP" }, - { stageType_t::ST_DISPERSIONMAP, "DISPERSIONMAP" }, - { stageType_t::ST_SKYBOXMAP, "SKYBOXMAP" }, - { stageType_t::ST_SCREENMAP, "SCREENMAP" }, - { stageType_t::ST_PORTALMAP, "PORTALMAP" }, - { stageType_t::ST_HEATHAZEMAP, "HEATHAZEMAP" }, - { stageType_t::ST_LIQUIDMAP, "LIQUIDMAP" }, - { stageType_t::ST_FOGMAP, "FOGMAP" }, - { stageType_t::ST_LIGHTMAP, "LIGHTMAP" }, - { stageType_t::ST_STYLELIGHTMAP, "STYLELIGHTMAP" }, - { stageType_t::ST_STYLECOLORMAP, "STYLECOLORMAP" }, - { stageType_t::ST_COLLAPSE_COLORMAP, "COLLAPSE_COLORMAP" }, - { stageType_t::ST_COLLAPSE_DIFFUSEMAP, "COLLAPSE_DIFFUSEMAP" }, - { stageType_t::ST_COLLAPSE_REFLECTIONMAP, "COLLAPSE_REFLECTIONMAP" }, - { stageType_t::ST_ATTENUATIONMAP_XY, "ATTENUATIONMAP_XY" }, - { stageType_t::ST_ATTENUATIONMAP_Z, "ATTENUATIONMAP_XZ" }, - }; - - const char *prefix = ri.Cmd_Argc() > 1 ? ri.Cmd_Argv( 1 ) : nullptr; - - // Header names - std::string num = "num"; - std::string shaderType = "shaderType"; - std::string shaderSort = "shaderSort"; - std::string stageType = "stageType"; - std::string interactLight = "interactLight"; - std::string stageNumber = "stageNumber"; - std::string shaderName = "shaderName"; - - // Number sizes - size_t numLen = 5; - - // Header number sizes - numLen = std::max( numLen, num.length() ); - size_t shaderTypeLen = shaderType.length(); - size_t shaderSortLen = shaderSort.length(); - size_t stageTypeLen = stageType.length(); - size_t interactLightLen = interactLight.length(); - - // Value size - for ( const auto& kv : shaderTypeName ) - { - shaderTypeLen = std::max( shaderTypeLen, kv.second.length() ); - } - - for ( const auto& kv : shaderSortName ) - { - shaderSortLen = std::max( shaderSortLen, kv.second.length() ); - } +public: + ListShadersCmd() : StaticCmd("listShaders", "list q3shaders currently registered in the renderer") {} - for ( const auto& kv : stageTypeName ) + void Run( const Cmd::Args &args ) const override { - stageTypeLen = std::max( stageTypeLen, kv.second.length() ); - } + static const std::unordered_map shaderTypeName = { + { shaderType_t::SHADER_2D, "2D" }, + { shaderType_t::SHADER_3D_DYNAMIC, "3D_DYNAMIC" }, + { shaderType_t::SHADER_3D_STATIC, "3D_STATIC" }, + { shaderType_t::SHADER_LIGHT, "LIGHT" }, + }; - std::string separator = " "; - std::stringstream lineStream; + static const std::unordered_map shaderSortName = { + { shaderSort_t::SS_BAD, "BAD" }, + { shaderSort_t::SS_PORTAL, "PORTAL" }, + { shaderSort_t::SS_DEPTH, "DEPTH" }, + { shaderSort_t::SS_ENVIRONMENT_FOG, "ENV_FOG" }, + { shaderSort_t::SS_ENVIRONMENT_NOFOG, "ENV_NOFOG" }, + { shaderSort_t::SS_OPAQUE, "OPAQUE" }, + { shaderSort_t::SS_DECAL, "DECAL" }, + { shaderSort_t::SS_SEE_THROUGH, "SEE_THROUGH" }, + { shaderSort_t::SS_BANNER, "BANNER" }, + { shaderSort_t::SS_FOG, "FOG" }, + { shaderSort_t::SS_UNDERWATER, "UNDERWATER" }, + { shaderSort_t::SS_WATER, "WATER" }, + { shaderSort_t::SS_FAR, "FAR" }, + { shaderSort_t::SS_MEDIUM, "MEDIUM" }, + { shaderSort_t::SS_CLOSE, "CLOSE" }, + { shaderSort_t::SS_BLEND0, "BLEND0" }, + { shaderSort_t::SS_BLEND1, "BLEND1" }, + { shaderSort_t::SS_BLEND2, "BLEND2" }, + { shaderSort_t::SS_BLEND3, "BLEND3" }, + { shaderSort_t::SS_BLEND6, "BLEND6" }, + { shaderSort_t::SS_ALMOST_NEAREST, "ALMOST_NEAREST" }, + { shaderSort_t::SS_NEAREST, "NEAREST" }, + { shaderSort_t::SS_POST_PROCESS, "POST_PROCESS" }, + }; - // Print header - lineStream << std::left; - lineStream << std::setw(numLen) << num << separator; - lineStream << std::setw(shaderTypeLen) << shaderType << separator; - lineStream << std::setw(shaderSortLen) << shaderSort << separator; - lineStream << std::setw(stageTypeLen) << stageType << separator; - lineStream << std::setw(interactLightLen) << interactLight << separator; - lineStream << stageNumber << ":" << shaderName; + static const std::unordered_map stageTypeName = { + { stageType_t::ST_COLORMAP, "COLORMAP" }, + { stageType_t::ST_GLOWMAP, "GLOWMAP" }, + { stageType_t::ST_DIFFUSEMAP, "DIFFUSEMAP" }, + { stageType_t::ST_NORMALMAP, "NORMALMAP" }, + { stageType_t::ST_HEIGHTMAP, "HEIGHTMAP" }, + { stageType_t::ST_PHYSICALMAP, "PHYSICALMAP" }, + { stageType_t::ST_SPECULARMAP, "SPECULARMAP" }, + { stageType_t::ST_REFLECTIONMAP, "REFLECTIONMAP" }, + { stageType_t::ST_REFRACTIONMAP, "REFRACTIONMAP" }, + { stageType_t::ST_DISPERSIONMAP, "DISPERSIONMAP" }, + { stageType_t::ST_SKYBOXMAP, "SKYBOXMAP" }, + { stageType_t::ST_SCREENMAP, "SCREENMAP" }, + { stageType_t::ST_PORTALMAP, "PORTALMAP" }, + { stageType_t::ST_HEATHAZEMAP, "HEATHAZEMAP" }, + { stageType_t::ST_LIQUIDMAP, "LIQUIDMAP" }, + { stageType_t::ST_FOGMAP, "FOGMAP" }, + { stageType_t::ST_LIGHTMAP, "LIGHTMAP" }, + { stageType_t::ST_STYLELIGHTMAP, "STYLELIGHTMAP" }, + { stageType_t::ST_STYLECOLORMAP, "STYLECOLORMAP" }, + { stageType_t::ST_COLLAPSE_COLORMAP, "COLLAPSE_COLORMAP" }, + { stageType_t::ST_COLLAPSE_DIFFUSEMAP, "COLLAPSE_DIFFUSEMAP" }, + { stageType_t::ST_COLLAPSE_REFLECTIONMAP, "COLLAPSE_REFLECTIONMAP" }, + { stageType_t::ST_ATTENUATIONMAP_XY, "ATTENUATIONMAP_XY" }, + { stageType_t::ST_ATTENUATIONMAP_Z, "ATTENUATIONMAP_XZ" }, + }; - std::string lineSeparator( lineStream.str().length(), '-' ); + const char *prefix = args.Argc() > 1 ? args.Argv( 1 ).c_str() : nullptr; - Log::CommandInteractionMessage( lineSeparator ); - Log::CommandInteractionMessage( lineStream.str() ); - Log::CommandInteractionMessage( lineSeparator ); + // Header names + std::string num = "num"; + std::string shaderType = "shaderType"; + std::string shaderSort = "shaderSort"; + std::string stageType = "stageType"; + std::string interactLight = "interactLight"; + std::string stageNumber = "stageNumber"; + std::string shaderName = "shaderName"; - size_t totalStageCount = 0; - size_t highestShaderStageCount = 0; + // Number sizes + size_t numLen = 5; - for ( int i = 0; i < tr.numShaders; i++ ) - { - shader_t *shader = ri.Cmd_Argc() > 2 ? tr.sortedShaders[ i ] : tr.shaders[ i ]; + // Header number sizes + numLen = std::max( numLen, num.length() ); + size_t shaderTypeLen = shaderType.length(); + size_t shaderSortLen = shaderSort.length(); + size_t stageTypeLen = stageType.length(); + size_t interactLightLen = interactLight.length(); - // Only display shaders starting with prefix if prefix is not empty. - if ( prefix && !Com_Filter( prefix, shader->name, false ) ) + // Value size + for ( const auto& kv : shaderTypeName ) { - continue; + shaderTypeLen = std::max( shaderTypeLen, kv.second.length() ); } - if ( !shaderTypeName.count( shader->type ) ) - { - Log::Debug( "Undocumented shader type %i for shader %s", - Util::ordinal( shader->type ), shader->name ); - } - else + for ( const auto& kv : shaderSortName ) { - shaderType = shaderTypeName.at( shader->type ); + shaderSortLen = std::max( shaderSortLen, kv.second.length() ); } - if ( !shaderSortName.count( (shaderSort_t) shader->sort ) ) - { - Log::Debug( "Undocumented shader sort %f for shader %s", - shader->sort, shader->name ); - } - else + for ( const auto& kv : stageTypeName ) { - shaderSort = shaderSortName.at( (shaderSort_t) shader->sort ); + stageTypeLen = std::max( stageTypeLen, kv.second.length() ); } - interactLight = shader->interactLight ? "INTERACTLIGHT" : ""; - shaderName = shader->name; - shaderName += shader->defaultShader ? " (DEFAULTED)" : ""; + std::string separator = " "; + std::stringstream lineStream; - if ( shader->stages == shader->lastStage ) - { - lineStream.clear(); - lineStream.str(""); + // Print header + lineStream << std::left; + lineStream << std::setw(numLen) << num << separator; + lineStream << std::setw(shaderTypeLen) << shaderType << separator; + lineStream << std::setw(shaderSortLen) << shaderSort << separator; + lineStream << std::setw(stageTypeLen) << stageType << separator; + lineStream << std::setw(interactLightLen) << interactLight << separator; + lineStream << stageNumber << ":" << shaderName; - lineStream << std::left; - lineStream << std::setw(numLen) << i << separator; - lineStream << std::setw(shaderTypeLen) << shaderType << separator; - lineStream << std::setw(shaderSortLen) << shaderSort << separator; - lineStream << std::setw(stageTypeLen) << stageType << separator; - lineStream << std::setw(interactLightLen) << interactLight << separator; - lineStream << "-:" << shaderName; + std::string lineSeparator( lineStream.str().length(), '-' ); - Log::CommandInteractionMessage( lineStream.str() ); - continue; - } + Print( lineSeparator ); + Print( lineStream.str() ); + Print( lineSeparator ); - const size_t stageCount = shader->lastStage - shader->stages; - totalStageCount += stageCount; - highestShaderStageCount = std::max( highestShaderStageCount, stageCount ); + size_t totalStageCount = 0; + size_t highestShaderStageCount = 0; - for ( size_t j = 0; j < stageCount; j++ ) + for ( int i = 0; i < tr.numShaders; i++ ) { - shaderStage_t *stage = &shader->stages[ j ]; + shader_t *shader = args.Argc() > 2 ? tr.sortedShaders[ i ] : tr.shaders[ i ]; - if ( !stageTypeName.count( stage->type ) ) + // Only display shaders starting with prefix if prefix is not empty. + if ( prefix && !Com_Filter( prefix, shader->name, false ) ) { - Log::Debug( "Undocumented stage type %i for shader stage %s:%d", - Util::ordinal( stage->type ), shader->name, j ); + continue; + } + + if ( !shaderTypeName.count( shader->type ) ) + { + Log::Debug( "Undocumented shader type %i for shader %s", + Util::ordinal( shader->type ), shader->name ); + } + else + { + shaderType = shaderTypeName.at( shader->type ); + } + + if ( !shaderSortName.count( (shaderSort_t) shader->sort ) ) + { + Log::Debug( "Undocumented shader sort %f for shader %s", + shader->sort, shader->name ); } else { - stageType = stageTypeName.at( stage->type ); + shaderSort = shaderSortName.at( (shaderSort_t) shader->sort ); } - lineStream.clear(); - lineStream.str(""); + interactLight = shader->interactLight ? "INTERACTLIGHT" : ""; + shaderName = shader->name; + shaderName += shader->defaultShader ? " (DEFAULTED)" : ""; - lineStream << std::left; - lineStream << std::setw(numLen) << i << separator; - lineStream << std::setw(shaderTypeLen) << shaderType << separator; - lineStream << std::setw(shaderSortLen) << shaderSort << separator; - lineStream << std::setw(stageTypeLen) << stageType << separator; - lineStream << std::setw(interactLightLen) << interactLight << separator; - lineStream << j << ":" << shaderName; + if ( shader->stages == shader->lastStage ) + { + lineStream.clear(); + lineStream.str(""); - Log::CommandInteractionMessage( lineStream.str() ); - } - } + lineStream << std::left; + lineStream << std::setw(numLen) << i << separator; + lineStream << std::setw(shaderTypeLen) << shaderType << separator; + lineStream << std::setw(shaderSortLen) << shaderSort << separator; + lineStream << std::setw(stageTypeLen) << stageType << separator; + lineStream << std::setw(interactLightLen) << interactLight << separator; + lineStream << "-:" << shaderName; - std::string summary = Str::Format( - "%i total shaders, %i total stages, largest shader has %i stages", - tr.numShaders, totalStageCount, highestShaderStageCount ); + Print( lineStream.str() ); + continue; + } - Log::CommandInteractionMessage( lineSeparator ); - Log::CommandInteractionMessage( summary ); - Log::CommandInteractionMessage( lineSeparator ); -} + const size_t stageCount = shader->lastStage - shader->stages; + totalStageCount += stageCount; + highestShaderStageCount = std::max( highestShaderStageCount, stageCount ); + + for ( size_t j = 0; j < stageCount; j++ ) + { + shaderStage_t *stage = &shader->stages[ j ]; + + if ( !stageTypeName.count( stage->type ) ) + { + Log::Debug( "Undocumented stage type %i for shader stage %s:%d", + Util::ordinal( stage->type ), shader->name, j ); + } + else + { + stageType = stageTypeName.at( stage->type ); + } + + lineStream.clear(); + lineStream.str(""); + + lineStream << std::left; + lineStream << std::setw(numLen) << i << separator; + lineStream << std::setw(shaderTypeLen) << shaderType << separator; + lineStream << std::setw(shaderSortLen) << shaderSort << separator; + lineStream << std::setw(stageTypeLen) << stageType << separator; + lineStream << std::setw(interactLightLen) << interactLight << separator; + lineStream << j << ":" << shaderName; + + Print( lineStream.str() ); + } + } + + Print( lineSeparator ); + Print( "%i total shaders, %i total stages, largest shader has %i stages", + tr.numShaders, totalStageCount, highestShaderStageCount ); + Print( lineSeparator ); + } +}; +static ListShadersCmd listShadersCmdRegistration; void R_ShaderExp_f() { diff --git a/src/engine/renderer/tr_skin.cpp b/src/engine/renderer/tr_skin.cpp index ef35eb2921..ee552a4a73 100644 --- a/src/engine/renderer/tr_skin.cpp +++ b/src/engine/renderer/tr_skin.cpp @@ -327,29 +327,31 @@ skin_t *R_GetSkinByHandle( qhandle_t hSkin ) return tr.skins[ hSkin ]; } -/* -=============== -R_ListSkins_f -=============== -*/ -void R_ListSkins_f() +class ListSkinsCmd : public Cmd::StaticCmd { - int i, j; - skin_t *skin; - - Log::Notice("------------------" ); +public: + ListSkinsCmd() : StaticCmd("listSkins", "list model skins") {} - for ( i = 0; i < tr.numSkins; i++ ) + void Run( const Cmd::Args & ) const override { - skin = tr.skins[ i ]; + int i, j; + skin_t *skin; - Log::Notice("%3i:%s", i, skin->name ); + Print("------------------" ); - for ( j = 0; j < skin->numSurfaces; j++ ) + for ( i = 0; i < tr.numSkins; i++ ) { - Log::Notice(" %s = %s", skin->surfaces[ j ]->name, skin->surfaces[ j ]->shader->name ); + skin = tr.skins[ i ]; + + Print("%3i:%s", i, skin->name ); + + for ( j = 0; j < skin->numSurfaces; j++ ) + { + Print(" %s = %s", skin->surfaces[ j ]->name, skin->surfaces[ j ]->shader->name ); + } } - } - Log::Notice("------------------" ); -} + Print("------------------" ); + } +}; +static ListSkinsCmd listSkinsCmdRegistration; From adf44ebb47c4f58f6301820692da58e4da89103e Mon Sep 17 00:00:00 2001 From: slipher Date: Tue, 7 Jan 2025 16:57:40 -0300 Subject: [PATCH 2/4] Don't call Cmd_RemoveCommand for nonexistent commands Some of them do exist, but are now implemented with new-style commands so the legacy interface shouldn't be used. --- src/engine/client/cl_main.cpp | 3 --- src/engine/renderer/tr_init.cpp | 2 -- src/engine/server/sv_ccmds.cpp | 1 - 3 files changed, 6 deletions(-) diff --git a/src/engine/client/cl_main.cpp b/src/engine/client/cl_main.cpp index 58c57ec421..13aab8ef7c 100644 --- a/src/engine/client/cl_main.cpp +++ b/src/engine/client/cl_main.cpp @@ -2474,18 +2474,15 @@ void CL_Shutdown() Cmd_RemoveCommand( "cmd" ); Cmd_RemoveCommand( "configstrings" ); - Cmd_RemoveCommand( "userinfo" ); Cmd_RemoveCommand( "snd_restart" ); Cmd_RemoveCommand( "vid_restart" ); Cmd_RemoveCommand( "disconnect" ); Cmd_RemoveCommand( "connect" ); Cmd_RemoveCommand( "localservers" ); Cmd_RemoveCommand( "globalservers" ); - Cmd_RemoveCommand( "rcon" ); Cmd_RemoveCommand( "ping" ); Cmd_RemoveCommand( "serverstatus" ); Cmd_RemoveCommand( "showip" ); - Cmd_RemoveCommand( "model" ); CL_ClearKeyBinding(); CL_ClearInput(); diff --git a/src/engine/renderer/tr_init.cpp b/src/engine/renderer/tr_init.cpp index 080c4ada28..e09709f312 100644 --- a/src/engine/renderer/tr_init.cpp +++ b/src/engine/renderer/tr_init.cpp @@ -1532,8 +1532,6 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p ri.Cmd_RemoveCommand( "shaderexp" ); ri.Cmd_RemoveCommand( "gfxinfo" ); - ri.Cmd_RemoveCommand( "shaderstate" ); - ri.Cmd_RemoveCommand( "generatemtr" ); ri.Cmd_RemoveCommand( "buildcubemaps" ); ri.Cmd_RemoveCommand( "glsl_restart" ); diff --git a/src/engine/server/sv_ccmds.cpp b/src/engine/server/sv_ccmds.cpp index e8f0be37a2..3598e153f7 100644 --- a/src/engine/server/sv_ccmds.cpp +++ b/src/engine/server/sv_ccmds.cpp @@ -451,6 +451,5 @@ void SV_RemoveOperatorCommands() Cmd_RemoveCommand( "heartbeat" ); Cmd_RemoveCommand( "map_restart" ); Cmd_RemoveCommand( "serverinfo" ); - Cmd_RemoveCommand( "status" ); Cmd_RemoveCommand( "systeminfo" ); } From d2a1634828731d5951260d44296de54ac5040297 Mon Sep 17 00:00:00 2001 From: slipher Date: Tue, 7 Jan 2025 17:38:49 -0300 Subject: [PATCH 3/4] Migrate remaining renderer commands to C++ interface --- src/engine/renderer/tr_bsp.cpp | 4 ++ src/engine/renderer/tr_init.cpp | 62 +++++++++++++++---------------- src/engine/renderer/tr_local.h | 1 - src/engine/renderer/tr_shader.cpp | 30 +++++++-------- 4 files changed, 48 insertions(+), 49 deletions(-) diff --git a/src/engine/renderer/tr_bsp.cpp b/src/engine/renderer/tr_bsp.cpp index e8a56f282f..f366f28379 100644 --- a/src/engine/renderer/tr_bsp.cpp +++ b/src/engine/renderer/tr_bsp.cpp @@ -5016,6 +5016,10 @@ void R_BuildCubeMaps() } } +static Cmd::LambdaCmd buildCubeMapsCmd( + "buildcubemaps", "generate cube probes for reflection mapping", + []( const Cmd::Args & ) { R_BuildCubeMaps(); }); + /* ================= RE_LoadWorldMap diff --git a/src/engine/renderer/tr_init.cpp b/src/engine/renderer/tr_init.cpp index e09709f312..92fc30f035 100644 --- a/src/engine/renderer/tr_init.cpp +++ b/src/engine/renderer/tr_init.cpp @@ -900,7 +900,7 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p GfxInfo_f ================ */ - void GfxInfo_f() + static void GfxInfo_f() { static const char fsstrings[][16] = { @@ -1079,31 +1079,44 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p Log::Debug("replaceMaterialMinDimensionIfPresentWithMaxDimension: %d", r_replaceMaterialMinDimensionIfPresentWithMaxDimension->integer ); } - static void GLSL_restart_f() - { - // make sure the render thread is stopped - R_SyncRenderThread(); + // FIXME: uses regular logging not Print() + static Cmd::LambdaCmd gfxInfoCmd( + "gfxinfo", "dump graphics driver and configuration info", + []( const Cmd::Args & ) { GfxInfo_f(); }); - GLSL_ShutdownGPUShaders(); - GLSL_InitGPUShaders(); + class GlslRestartCmd : public Cmd::StaticCmd + { + public: + GlslRestartCmd() : StaticCmd( + "glsl_restart", "recompile GLSL shaders (useful when shaderpath is set)") {} - for ( int i = 0; i < tr.numShaders; i++ ) + void Run( const Cmd::Args & ) const override { - shader_t &shader = *tr.shaders[ i ]; - if ( shader.stages == shader.lastStage || shader.stages[ 0 ].deformIndex == 0 ) - { - continue; - } + // make sure the render thread is stopped + R_SyncRenderThread(); - int deformIndex = - gl_shaderManager.getDeformShaderIndex( shader.deforms, shader.numDeforms ); + GLSL_ShutdownGPUShaders(); + GLSL_InitGPUShaders(); - for ( shaderStage_t *stage = shader.stages; stage != shader.lastStage; stage++ ) + for ( int i = 0; i < tr.numShaders; i++ ) { - stage->deformIndex = deformIndex; + shader_t &shader = *tr.shaders[ i ]; + if ( shader.stages == shader.lastStage || shader.stages[ 0 ].deformIndex == 0 ) + { + continue; + } + + int deformIndex = + gl_shaderManager.getDeformShaderIndex( shader.deforms, shader.numDeforms ); + + for ( shaderStage_t *stage = shader.stages; stage != shader.lastStage; stage++ ) + { + stage->deformIndex = deformIndex; + } } } - } + }; + static GlslRestartCmd glslRestartCmdRegistration; /* =============== @@ -1351,13 +1364,6 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p r_showParallelShadowSplits = Cvar_Get( "r_showParallelShadowSplits", "0", CVAR_CHEAT | CVAR_LATCH ); Cvar::Latch( r_profilerRenderSubGroups ); - - // make sure all the commands added here are also removed in R_Shutdown - ri.Cmd_AddCommand( "shaderexp", R_ShaderExp_f ); - ri.Cmd_AddCommand( "gfxinfo", GfxInfo_f ); - ri.Cmd_AddCommand( "buildcubemaps", R_BuildCubeMaps ); - - ri.Cmd_AddCommand( "glsl_restart", GLSL_restart_f ); } /* @@ -1530,12 +1536,6 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p { Log::Debug("RE_Shutdown( destroyWindow = %i )", destroyWindow ); - ri.Cmd_RemoveCommand( "shaderexp" ); - ri.Cmd_RemoveCommand( "gfxinfo" ); - ri.Cmd_RemoveCommand( "buildcubemaps" ); - - ri.Cmd_RemoveCommand( "glsl_restart" ); - if ( tr.registered ) { R_SyncRenderThread(); diff --git a/src/engine/renderer/tr_local.h b/src/engine/renderer/tr_local.h index a81e8249fa..df1a70d538 100644 --- a/src/engine/renderer/tr_local.h +++ b/src/engine/renderer/tr_local.h @@ -3303,7 +3303,6 @@ inline bool checkGLErrors() shader_t *R_FindShaderByName( const char *name ); const char *RE_GetShaderNameFromHandle( qhandle_t shader ); void R_InitShaders(); - void R_ShaderExp_f(); void R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset ); /* diff --git a/src/engine/renderer/tr_shader.cpp b/src/engine/renderer/tr_shader.cpp index 57b6767e09..f5c2b10184 100644 --- a/src/engine/renderer/tr_shader.cpp +++ b/src/engine/renderer/tr_shader.cpp @@ -6855,28 +6855,24 @@ class ListShadersCmd : public Cmd::StaticCmd }; static ListShadersCmd listShadersCmdRegistration; -void R_ShaderExp_f() +class ShaderExpCmd : public Cmd::StaticCmd { - std::string buffer; +public: + ShaderExpCmd() : StaticCmd("shaderexp", "evaluate a q3shader expression (RB_EvalExpression)") {} - for ( int i = 1; i < ri.Cmd_Argc(); i++ ) + void Run( const Cmd::Args &args ) const override { - if ( i > 1 ) - { - buffer += ' '; - } - - buffer += ri.Cmd_Argv( i ); - } - - const char* buffer_p = buffer.c_str(); - expression_t exp; + std::string expStr = args.ConcatArgs( 1 ); + const char* buffer_p = expStr.c_str(); + expression_t exp; - ParseExpression( &buffer_p, &exp ); + ParseExpression( &buffer_p, &exp ); - Log::CommandInteractionMessage( Str::Format( "%i total ops", exp.numOps ) ); - Log::CommandInteractionMessage( Str::Format( "%f result", RB_EvalExpression( &exp, 0 ) ) ); -} + Print( "%i total ops", exp.numOps ); + Print( "%f result", RB_EvalExpression( &exp, 0 ) ); + } +}; +static ShaderExpCmd shaderExpCmdRegistration; /* ==================== From 0b5e63c1caeb288b29c3d2a8993716c9ff230291 Mon Sep 17 00:00:00 2001 From: slipher Date: Tue, 7 Jan 2025 17:39:21 -0300 Subject: [PATCH 4/4] Remove legacy command interface from renderer interface --- src/engine/client/cl_main.cpp | 6 ------ src/engine/renderer/tr_public.h | 8 -------- src/engine/sys/sdl_glimp.cpp | 9 +++------ 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/engine/client/cl_main.cpp b/src/engine/client/cl_main.cpp index 13aab8ef7c..c98bc13f66 100644 --- a/src/engine/client/cl_main.cpp +++ b/src/engine/client/cl_main.cpp @@ -2219,12 +2219,6 @@ static bool CL_InitRef() refimport_t ri; refexport_t *ret; - ri.Cmd_AddCommand = Cmd_AddCommand; - ri.Cmd_RemoveCommand = Cmd_RemoveCommand; - ri.Cmd_Argc = Cmd_Argc; - ri.Cmd_Argv = Cmd_Argv; - ri.Cmd_QuoteString = Cmd_QuoteString; - ri.Milliseconds = Sys::Milliseconds; ri.RealTime = Com_RealTime; diff --git a/src/engine/renderer/tr_public.h b/src/engine/renderer/tr_public.h index d1d2b9b0df..038c069489 100644 --- a/src/engine/renderer/tr_public.h +++ b/src/engine/renderer/tr_public.h @@ -293,14 +293,6 @@ struct refimport_t void *( *Hunk_AllocateTempMemory )( int size ); void ( *Hunk_FreeTempMemory )( void *block ); - void ( *Cmd_AddCommand )( const char *name, void ( *cmd )() ); - void ( *Cmd_RemoveCommand )( const char *name ); - - int ( *Cmd_Argc )(); - const char *( *Cmd_Argv )( int i ); - - const char *( *Cmd_QuoteString )( const char *text ); - // a -1 return means the file does not exist // nullptr can be passed for buf to just determine existence int ( *FS_ReadFile )( const char *name, void **buf ); diff --git a/src/engine/sys/sdl_glimp.cpp b/src/engine/sys/sdl_glimp.cpp index 500a94362d..d484be43f8 100644 --- a/src/engine/sys/sdl_glimp.cpp +++ b/src/engine/sys/sdl_glimp.cpp @@ -500,10 +500,9 @@ void GLimp_Shutdown() ResetStruct( glState ); } -static void GLimp_Minimize() -{ - SDL_MinimizeWindow( window ); -} +static Cmd::LambdaCmd minimizeCmd( + "minimize", "minimize the window", + []( const Cmd::Args & ) { SDL_MinimizeWindow( window ); }); static void SetSwapInterval( int swapInterval ) { @@ -2655,8 +2654,6 @@ bool GLimp_Init() Cvar::Latch( workaround_glExtension_missingArbFbo_useExtFbo ); Cvar::Latch( workaround_glHardware_intel_useFirstProvokinVertex ); - ri.Cmd_AddCommand( "minimize", GLimp_Minimize ); - /* Enable S3TC on Mesa even if libtxc-dxtn is not available The environment variables is currently always set, it should do nothing with other systems and drivers.