2012-11-26 18:58:24 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Doom 3 BFG Edition GPL Source Code
2012-11-28 15:47:07 +00:00
Copyright ( C ) 1993 - 2012 id Software LLC , a ZeniMax Media company .
2024-02-25 20:08:27 +00:00
Copyright ( C ) 2014 - 2024 Robert Beckebans
2016-06-13 20:29:31 +00:00
Copyright ( C ) 2014 - 2016 Kot in Action Creative Artel
2022-02-21 16:59:13 +00:00
Copyright ( C ) 2022 Stephen Pridham
2012-11-26 18:58:24 +00:00
2012-11-28 15:47:07 +00:00
This file is part of the Doom 3 BFG Edition GPL Source Code ( " Doom 3 BFG Edition Source Code " ) .
2012-11-26 18:58:24 +00:00
Doom 3 BFG Edition Source Code is free software : you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation , either version 3 of the License , or
( at your option ) any later version .
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code . If not , see < http : //www.gnu.org/licenses/>.
In addition , the Doom 3 BFG Edition Source Code is also subject to certain additional terms . You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code . If not , please request a copy in writing from id Software at the address below .
If you have questions concerning this license or the applicable additional terms , you may contact in writing id Software LLC , c / o ZeniMax Media Inc . , Suite 120 , Rockville , Maryland 20850 USA .
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-12-22 15:18:19 +00:00
# include "precompiled.h"
2021-07-29 13:42:02 +00:00
# pragma hdrstop
2012-11-26 18:58:24 +00:00
2023-01-25 17:27:32 +00:00
# include "imgui.h"
2024-08-27 09:41:39 +00:00
# if defined(USE_INTRINSICS_SSE)
2024-08-30 16:41:03 +00:00
# if MOC_MULTITHREADED
2024-09-02 19:00:01 +00:00
# include "CullingThreadPool.h"
2024-08-30 16:41:03 +00:00
# else
# include "../libs/moc/MaskedOcclusionCulling.h"
# endif
2024-08-27 09:41:39 +00:00
# endif
2021-05-06 11:31:58 +00:00
2017-09-03 08:22:36 +00:00
# include "RenderCommon.h"
2012-11-26 18:58:24 +00:00
2023-03-10 18:25:56 +00:00
# include "sys/DeviceManager.h"
2022-02-21 18:56:21 +00:00
2012-12-07 16:06:44 +00:00
// RB begin
# if defined(_WIN32)
2019-11-11 19:27:44 +00:00
// Vista OpenGL wrapper check
# include "../sys/win32/win_local.h"
2012-12-07 16:06:44 +00:00
# endif
// RB end
2012-11-26 18:58:24 +00:00
2016-06-13 20:29:31 +00:00
// foresthale 2014-03-01: fixed custom screenshot resolution by doing a more direct render path
# define BUGFIXEDSCREENSHOTRESOLUTION 1
# ifdef BUGFIXEDSCREENSHOTRESOLUTION
2019-11-11 19:27:44 +00:00
# include "../framework/Common_local.h"
2016-06-13 20:29:31 +00:00
# endif
2022-02-21 18:56:21 +00:00
2012-11-26 18:58:24 +00:00
// DeviceContext bypasses RenderSystem to work directly with this
2012-11-28 15:47:07 +00:00
idGuiModel * tr_guiModel ;
2012-11-26 18:58:24 +00:00
// functions that are not called every frame
glconfig_t glConfig ;
idCVar r_requestStereoPixelFormat ( " r_requestStereoPixelFormat " , " 1 " , CVAR_RENDERER , " Ask for a stereo GL pixel format on startup " ) ;
idCVar r_debugContext ( " r_debugContext " , " 0 " , CVAR_RENDERER , " Enable various levels of context debug. " ) ;
2023-03-10 18:25:56 +00:00
# if defined( _WIN32 )
2024-07-10 18:33:20 +00:00
idCVar r_graphicsAPI ( " r_graphicsAPI " , " dx12 " , CVAR_RENDERER | CVAR_INIT | CVAR_ARCHIVE | CVAR_NEW , " Specifies the graphics api to use (dx12, vulkan) " ) ;
2023-03-10 18:25:56 +00:00
# else
2024-07-10 18:33:20 +00:00
idCVar r_graphicsAPI ( " r_graphicsAPI " , " vulkan " , CVAR_RENDERER | CVAR_ROM | CVAR_STATIC | CVAR_NEW , " Specifies the graphics api to use (vulkan) " ) ;
2022-03-22 10:16:44 +00:00
# endif
2023-03-10 18:25:56 +00:00
2024-07-10 18:33:20 +00:00
idCVar r_useValidationLayers ( " r_useValidationLayers " , " 1 " , CVAR_INTEGER | CVAR_INIT | CVAR_NEW , " 1 is just the NVRHI and 2 will turn on additional DX12, VK validation layers " ) ;
2023-03-10 18:25:56 +00:00
2014-05-16 21:57:17 +00:00
// RB: disabled 16x MSAA
2022-05-29 13:51:07 +00:00
# if ID_MSAA
2024-07-10 18:33:20 +00:00
idCVar r_antiAliasing ( " r_antiAliasing " , " 1 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER | CVAR_NEW , " 0 = None \n 1 = TAA 1x \n 2 = TAA + SMAA 1x \n 3 = MSAA 2x \n 4 = MSAA 4x \n " , 0 , ANTI_ALIASING_MSAA_4X ) ;
2022-05-29 13:51:07 +00:00
# else
2024-11-28 15:38:10 +00:00
idCVar r_antiAliasing ( " r_antiAliasing " , " 2 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER | CVAR_NEW , " 0 = None \n 1 = SMAA 1x, 2 = TAA " , 0 , ANTI_ALIASING_TAA ) ;
2022-05-29 13:51:07 +00:00
# endif
2014-05-16 21:57:17 +00:00
// RB end
2012-11-26 18:58:24 +00:00
idCVar r_vidMode ( " r_vidMode " , " 0 " , CVAR_ARCHIVE | CVAR_RENDERER | CVAR_INTEGER , " fullscreen video mode number " ) ;
idCVar r_displayRefresh ( " r_displayRefresh " , " 0 " , CVAR_RENDERER | CVAR_INTEGER | CVAR_NOCHEAT , " optional display refresh rate option for vid mode " , 0.0f , 240.0f ) ;
2023-03-15 03:05:00 +00:00
// SRS - redefined mode -2 to be borderless fullscreen, implemented borderless modes -2 and -1 for Windows and linux/macOS (SDL)
// DG: add mode -2 for SDL, also defaulting to windowed mode, as that causes less trouble on linux
idCVar r_fullscreen ( " r_fullscreen " , " 0 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER , " -2 = borderless fullscreen, -1 = borderless window, 0 = windowed, 1 = full screen on monitor 1, 2 = full screen on monitor 2, etc " ) ;
// DG end
2012-11-26 18:58:24 +00:00
idCVar r_customWidth ( " r_customWidth " , " 1280 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER , " custom screen width. set r_vidMode to -1 to activate " ) ;
idCVar r_customHeight ( " r_customHeight " , " 720 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER , " custom screen height. set r_vidMode to -1 to activate " ) ;
idCVar r_windowX ( " r_windowX " , " 0 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER , " Non-fullscreen parameter " ) ;
idCVar r_windowY ( " r_windowY " , " 0 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER , " Non-fullscreen parameter " ) ;
idCVar r_windowWidth ( " r_windowWidth " , " 1280 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER , " Non-fullscreen parameter " ) ;
idCVar r_windowHeight ( " r_windowHeight " , " 720 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER , " Non-fullscreen parameter " ) ;
idCVar r_useViewBypass ( " r_useViewBypass " , " 1 " , CVAR_RENDERER | CVAR_INTEGER , " bypass a frame of latency to the view " ) ;
idCVar r_useLightPortalFlow ( " r_useLightPortalFlow " , " 1 " , CVAR_RENDERER | CVAR_BOOL , " use a more precise area reference determination " ) ;
idCVar r_singleTriangle ( " r_singleTriangle " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " only draw a single triangle per primitive " ) ;
idCVar r_checkBounds ( " r_checkBounds " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " compare all surface bounds with precalculated ones " ) ;
2024-06-17 19:37:10 +00:00
2012-11-26 18:58:24 +00:00
idCVar r_useNodeCommonChildren ( " r_useNodeCommonChildren " , " 1 " , CVAR_RENDERER | CVAR_BOOL , " stop pushing reference bounds early when possible " ) ;
idCVar r_useShadowSurfaceScissor ( " r_useShadowSurfaceScissor " , " 1 " , CVAR_RENDERER | CVAR_BOOL , " scissor shadows by the scissor rect of the interaction surfaces " ) ;
2024-06-18 18:33:11 +00:00
2012-11-26 18:58:24 +00:00
idCVar r_maxAnisotropicFiltering ( " r_maxAnisotropicFiltering " , " 8 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER , " limit aniso filtering " ) ;
idCVar r_useTrilinearFiltering ( " r_useTrilinearFiltering " , " 1 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL , " Extra quality filtering " ) ;
2014-05-15 21:46:53 +00:00
// RB: not used anymore
2021-10-30 15:54:07 +00:00
idCVar r_lodBias ( " r_lodBias " , " 0.5 " , CVAR_RENDERER | CVAR_ARCHIVE , " UNUSED: image lod bias " ) ;
2014-05-15 21:46:53 +00:00
// RB end
2012-11-26 18:58:24 +00:00
idCVar r_useStateCaching ( " r_useStateCaching " , " 1 " , CVAR_RENDERER | CVAR_BOOL , " avoid redundant state changes in GL_*() calls " ) ;
idCVar r_znear ( " r_znear " , " 3 " , CVAR_RENDERER | CVAR_FLOAT , " near Z clip plane distance " , 0.001f , 200.0f ) ;
2020-07-14 16:37:41 +00:00
idCVar r_ignoreGLErrors ( " r_ignoreGLErrors " , " 1 " , CVAR_RENDERER | CVAR_BOOL , " ignore GL errors " ) ;
2012-11-26 18:58:24 +00:00
idCVar r_swapInterval ( " r_swapInterval " , " 1 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER , " 0 = tear, 1 = swap-tear where available, 2 = always v-sync " ) ;
idCVar r_gamma ( " r_gamma " , " 1.0 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_FLOAT , " changes gamma tables " , 0.5f , 3.0f ) ;
idCVar r_brightness ( " r_brightness " , " 1 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_FLOAT , " changes gamma tables " , 0.5f , 2.0f ) ;
idCVar r_skipStaticInteractions ( " r_skipStaticInteractions " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " skip interactions created at level load " ) ;
idCVar r_skipDynamicInteractions ( " r_skipDynamicInteractions " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " skip interactions created after level load " ) ;
idCVar r_skipSuppress ( " r_skipSuppress " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " ignore the per-view suppressions " ) ;
2023-03-10 17:49:32 +00:00
idCVar r_skipPostProcess ( " r_skipPostProcess " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " skip all post-process renderings except bloom " ) ;
2021-06-23 21:26:41 +00:00
idCVar r_skipBloom ( " r_skipBloom " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " Skip bloom " ) ;
2012-11-26 18:58:24 +00:00
idCVar r_skipInteractions ( " r_skipInteractions " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " skip all light/surface interaction drawing " ) ;
idCVar r_skipDynamicTextures ( " r_skipDynamicTextures " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " don't dynamically create textures " ) ;
idCVar r_skipCopyTexture ( " r_skipCopyTexture " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " do all rendering, but don't actually copyTexSubImage2D " ) ;
idCVar r_skipBackEnd ( " r_skipBackEnd " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " don't draw anything " ) ;
idCVar r_skipRender ( " r_skipRender " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " skip 3D rendering, but pass 2D " ) ;
idCVar r_skipTranslucent ( " r_skipTranslucent " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " skip the translucent interaction rendering " ) ;
idCVar r_skipAmbient ( " r_skipAmbient " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " bypasses all non-interaction drawing " ) ;
idCVar r_skipNewAmbient ( " r_skipNewAmbient " , " 0 " , CVAR_RENDERER | CVAR_BOOL | CVAR_ARCHIVE , " bypasses all vertex/fragment program ambient drawing " ) ;
idCVar r_skipBlendLights ( " r_skipBlendLights " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " skip all blend lights " ) ;
idCVar r_skipFogLights ( " r_skipFogLights " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " skip all fog lights " ) ;
idCVar r_skipDeforms ( " r_skipDeforms " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " leave all deform materials in their original state " ) ;
idCVar r_skipFrontEnd ( " r_skipFrontEnd " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " bypasses all front end work, but 2D gui rendering still draws " ) ;
idCVar r_skipUpdates ( " r_skipUpdates " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " 1 = don't accept any entity or light updates, making everything static " ) ;
idCVar r_skipDecals ( " r_skipDecals " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " skip decal surfaces " ) ;
idCVar r_skipOverlays ( " r_skipOverlays " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " skip overlay surfaces " ) ;
idCVar r_skipSpecular ( " r_skipSpecular " , " 0 " , CVAR_RENDERER | CVAR_BOOL | CVAR_CHEAT | CVAR_ARCHIVE , " use black for specular1 " ) ;
idCVar r_skipBump ( " r_skipBump " , " 0 " , CVAR_RENDERER | CVAR_BOOL | CVAR_ARCHIVE , " uses a flat surface instead of the bump map " ) ;
2022-04-13 20:05:05 +00:00
idCVar r_skipDiffuse ( " r_skipDiffuse " , " 0 " , CVAR_RENDERER | CVAR_INTEGER , " use black for diffuse " ) ;
2012-11-26 18:58:24 +00:00
idCVar r_skipSubviews ( " r_skipSubviews " , " 0 " , CVAR_RENDERER | CVAR_INTEGER , " 1 = don't render any gui elements on surfaces " ) ;
2012-11-28 15:47:07 +00:00
idCVar r_skipGuiShaders ( " r_skipGuiShaders " , " 0 " , CVAR_RENDERER | CVAR_INTEGER , " 1 = skip all gui elements on surfaces, 2 = skip drawing but still handle events, 3 = draw but skip events " , 0 , 3 , idCmdSystem : : ArgCompletion_Integer < 0 , 3 > ) ;
idCVar r_skipParticles ( " r_skipParticles " , " 0 " , CVAR_RENDERER | CVAR_INTEGER , " 1 = skip all particle systems " , 0 , 1 , idCmdSystem : : ArgCompletion_Integer < 0 , 1 > ) ;
2012-11-26 18:58:24 +00:00
idCVar r_skipShadows ( " r_skipShadows " , " 0 " , CVAR_RENDERER | CVAR_BOOL | CVAR_ARCHIVE , " disable shadows " ) ;
2012-11-28 15:47:07 +00:00
idCVar r_useLightPortalCulling ( " r_useLightPortalCulling " , " 1 " , CVAR_RENDERER | CVAR_INTEGER , " 0 = none, 1 = cull frustum corners to plane, 2 = exact clip the frustum faces " , 0 , 2 , idCmdSystem : : ArgCompletion_Integer < 0 , 2 > ) ;
2012-11-26 18:58:24 +00:00
idCVar r_useLightAreaCulling ( " r_useLightAreaCulling " , " 1 " , CVAR_RENDERER | CVAR_BOOL , " 0 = off, 1 = on " ) ;
2012-11-28 15:47:07 +00:00
idCVar r_useLightScissors ( " r_useLightScissors " , " 3 " , CVAR_RENDERER | CVAR_INTEGER , " 0 = no scissor, 1 = non-clipped scissor, 2 = near-clipped scissor, 3 = fully-clipped scissor " , 0 , 3 , idCmdSystem : : ArgCompletion_Integer < 0 , 3 > ) ;
idCVar r_useEntityPortalCulling ( " r_useEntityPortalCulling " , " 1 " , CVAR_RENDERER | CVAR_INTEGER , " 0 = none, 1 = cull frustum corners to plane, 2 = exact clip the frustum faces " , 0 , 2 , idCmdSystem : : ArgCompletion_Integer < 0 , 2 > ) ;
2024-11-28 15:38:10 +00:00
idCVar r_clear ( " r_clear " , " 2 " , CVAR_RENDERER | CVAR_NOCHEAT , " force screen clear every frame, 1 = purple, 2 = black, 'r g b' = custom " ) ;
2012-11-26 18:58:24 +00:00
idCVar r_offsetFactor ( " r_offsetfactor " , " 0 " , CVAR_RENDERER | CVAR_FLOAT , " polygon offset parameter " ) ;
2015-12-20 11:28:46 +00:00
// RB: offset factor was 0, and units were -600 which caused some very ugly polygon offsets on Android so I reverted the values to the same as in Q3A
# if defined(__ANDROID__)
2019-11-11 19:27:44 +00:00
idCVar r_offsetUnits ( " r_offsetunits " , " -2 " , CVAR_RENDERER | CVAR_FLOAT , " polygon offset parameter " ) ;
2015-12-20 11:28:46 +00:00
# else
2019-11-11 19:27:44 +00:00
idCVar r_offsetUnits ( " r_offsetunits " , " -600 " , CVAR_RENDERER | CVAR_FLOAT , " polygon offset parameter " ) ;
2015-12-20 11:28:46 +00:00
# endif
// RB end
2012-11-26 18:58:24 +00:00
idCVar r_shadowPolygonOffset ( " r_shadowPolygonOffset " , " -1 " , CVAR_RENDERER | CVAR_FLOAT , " bias value added to depth test for stencil shadow drawing " ) ;
idCVar r_shadowPolygonFactor ( " r_shadowPolygonFactor " , " 0 " , CVAR_RENDERER | CVAR_FLOAT , " scale value for stencil shadow drawing " ) ;
idCVar r_subviewOnly ( " r_subviewOnly " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " 1 = don't render main view, allowing subviews to be debugged " ) ;
idCVar r_testGamma ( " r_testGamma " , " 0 " , CVAR_RENDERER | CVAR_FLOAT , " if > 0 draw a grid pattern to test gamma levels " , 0 , 195 ) ;
idCVar r_testGammaBias ( " r_testGammaBias " , " 0 " , CVAR_RENDERER | CVAR_FLOAT , " if > 0 draw a grid pattern to test gamma levels " ) ;
2016-01-13 23:59:41 +00:00
idCVar r_lightScale ( " r_lightScale " , " 3 " , CVAR_ARCHIVE | CVAR_RENDERER | CVAR_FLOAT , " all light intensities are multiplied by this " , 0 , 100 ) ;
2012-11-28 15:47:07 +00:00
idCVar r_flareSize ( " r_flareSize " , " 1 " , CVAR_RENDERER | CVAR_FLOAT , " scale the flare deforms from the material def " ) ;
2012-11-26 18:58:24 +00:00
2024-01-17 04:59:40 +00:00
idCVar r_useScissor ( " r_useScissor " , " 1 " , CVAR_RENDERER | CVAR_BOOL | CVAR_NOCHEAT , " scissor clip as portals and lights are processed " ) ;
2012-11-26 18:58:24 +00:00
idCVar r_useLightDepthBounds ( " r_useLightDepthBounds " , " 1 " , CVAR_RENDERER | CVAR_BOOL , " use depth bounds test on lights to reduce both shadow and interaction fill " ) ;
idCVar r_useShadowDepthBounds ( " r_useShadowDepthBounds " , " 1 " , CVAR_RENDERER | CVAR_BOOL , " use depth bounds test on individual shadow volumes to reduce shadow fill " ) ;
idCVar r_screenFraction ( " r_screenFraction " , " 100 " , CVAR_RENDERER | CVAR_INTEGER , " for testing fill rate, the resolution of the entire screen can be changed " ) ;
idCVar r_usePortals ( " r_usePortals " , " 1 " , CVAR_RENDERER | CVAR_BOOL , " 1 = use portals to perform area culling, otherwise draw everything " ) ;
idCVar r_singleLight ( " r_singleLight " , " -1 " , CVAR_RENDERER | CVAR_INTEGER , " suppress all but one light " ) ;
idCVar r_singleEntity ( " r_singleEntity " , " -1 " , CVAR_RENDERER | CVAR_INTEGER , " suppress all but one entity " ) ;
2024-07-10 18:33:20 +00:00
idCVar r_singleEnvprobe ( " r_singleEnvprobe " , " -1 " , CVAR_RENDERER | CVAR_INTEGER | CVAR_NEW , " suppress all but one environment probe " ) ;
2012-11-26 18:58:24 +00:00
idCVar r_singleSurface ( " r_singleSurface " , " -1 " , CVAR_RENDERER | CVAR_INTEGER , " suppress all but one surface on each entity " ) ;
idCVar r_singleArea ( " r_singleArea " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " only draw the portal area the view is actually in " ) ;
idCVar r_orderIndexes ( " r_orderIndexes " , " 1 " , CVAR_RENDERER | CVAR_BOOL , " perform index reorganization to optimize vertex use " ) ;
2023-03-29 19:20:19 +00:00
idCVar r_lightAllBackFaces ( " r_lightAllBackFaces " , " 1 " , CVAR_RENDERER | CVAR_BOOL , " light all the back faces, even when they would be shadowed " ) ;
2012-11-26 18:58:24 +00:00
// visual debugging info
idCVar r_showPortals ( " r_showPortals " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " draw portal outlines in color based on passed / not passed " ) ;
idCVar r_showUnsmoothedTangents ( " r_showUnsmoothedTangents " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " if 1, put all nvidia register combiner programming in display lists " ) ;
idCVar r_showSilhouette ( " r_showSilhouette " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " highlight edges that are casting shadow planes " ) ;
idCVar r_showVertexColor ( " r_showVertexColor " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " draws all triangles with the solid vertex color " ) ;
idCVar r_showUpdates ( " r_showUpdates " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " report entity and light updates and ref counts " ) ;
idCVar r_showDynamic ( " r_showDynamic " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " report stats on dynamic surface generation " ) ;
2012-11-28 15:47:07 +00:00
idCVar r_showTrace ( " r_showTrace " , " 0 " , CVAR_RENDERER | CVAR_INTEGER , " show the intersection of an eye trace with the world " , idCmdSystem : : ArgCompletion_Integer < 0 , 2 > ) ;
2012-11-26 18:58:24 +00:00
idCVar r_showIntensity ( " r_showIntensity " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " draw the screen colors based on intensity, red = 0, green = 128, blue = 255 " ) ;
2012-11-28 15:47:07 +00:00
idCVar r_showLights ( " r_showLights " , " 0 " , CVAR_RENDERER | CVAR_INTEGER , " 1 = just print volumes numbers, highlighting ones covering the view, 2 = also draw planes of each volume, 3 = also draw edges of each volume " , 0 , 3 , idCmdSystem : : ArgCompletion_Integer < 0 , 3 > ) ;
idCVar r_showShadows ( " r_showShadows " , " 0 " , CVAR_RENDERER | CVAR_INTEGER , " 1 = visualize the stencil shadow volumes, 2 = draw filled in " , 0 , 3 , idCmdSystem : : ArgCompletion_Integer < 0 , 3 > ) ;
2012-11-26 18:58:24 +00:00
idCVar r_showLightScissors ( " r_showLightScissors " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " show light scissor rectangles " ) ;
2012-11-28 15:47:07 +00:00
idCVar r_showLightCount ( " r_showLightCount " , " 0 " , CVAR_RENDERER | CVAR_INTEGER , " 1 = colors surfaces based on light count, 2 = also count everything through walls, 3 = also print overdraw " , 0 , 3 , idCmdSystem : : ArgCompletion_Integer < 0 , 3 > ) ;
2012-11-26 18:58:24 +00:00
idCVar r_showViewEntitys ( " r_showViewEntitys " , " 0 " , CVAR_RENDERER | CVAR_INTEGER , " 1 = displays the bounding boxes of all view models, 2 = print index numbers " ) ;
2012-11-28 15:47:07 +00:00
idCVar r_showTris ( " r_showTris " , " 0 " , CVAR_RENDERER | CVAR_INTEGER , " enables wireframe rendering of the world, 1 = only draw visible ones, 2 = draw all front facing, 3 = draw all, 4 = draw with alpha " , 0 , 4 , idCmdSystem : : ArgCompletion_Integer < 0 , 4 > ) ;
2012-11-26 18:58:24 +00:00
idCVar r_showSurfaceInfo ( " r_showSurfaceInfo " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " show surface material name under crosshair " ) ;
idCVar r_showNormals ( " r_showNormals " , " 0 " , CVAR_RENDERER | CVAR_FLOAT , " draws wireframe normals " ) ;
idCVar r_showMemory ( " r_showMemory " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " print frame memory utilization " ) ;
idCVar r_showCull ( " r_showCull " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " report sphere and box culling stats " ) ;
idCVar r_showAddModel ( " r_showAddModel " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " report stats from tr_addModel " ) ;
idCVar r_showDepth ( " r_showDepth " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " display the contents of the depth buffer and the depth range " ) ;
idCVar r_showSurfaces ( " r_showSurfaces " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " report surface/light/shadow counts " ) ;
idCVar r_showPrimitives ( " r_showPrimitives " , " 0 " , CVAR_RENDERER | CVAR_INTEGER , " report drawsurf/index/vertex counts " ) ;
idCVar r_showEdges ( " r_showEdges " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " draw the sil edges " ) ;
idCVar r_showTexturePolarity ( " r_showTexturePolarity " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " shade triangles by texture area polarity " ) ;
2012-11-28 15:47:07 +00:00
idCVar r_showTangentSpace ( " r_showTangentSpace " , " 0 " , CVAR_RENDERER | CVAR_INTEGER , " shade triangles by tangent space, 1 = use 1st tangent vector, 2 = use 2nd tangent vector, 3 = use normal vector " , 0 , 3 , idCmdSystem : : ArgCompletion_Integer < 0 , 3 > ) ;
2012-11-26 18:58:24 +00:00
idCVar r_showDominantTri ( " r_showDominantTri " , " 0 " , CVAR_RENDERER | CVAR_BOOL , " draw lines from vertexes to center of dominant triangles " ) ;
idCVar r_showTextureVectors ( " r_showTextureVectors " , " 0 " , CVAR_RENDERER | CVAR_FLOAT , " if > 0 draw each triangles texture (tangent) vectors " ) ;
2012-11-28 15:47:07 +00:00
idCVar r_showOverDraw ( " r_showOverDraw " , " 0 " , CVAR_RENDERER | CVAR_INTEGER , " 1 = geometry overdraw, 2 = light interaction overdraw, 3 = geometry and light interaction overdraw " , 0 , 3 , idCmdSystem : : ArgCompletion_Integer < 0 , 3 > ) ;
2014-05-10 12:40:01 +00:00
// RB begin
2024-07-10 18:33:20 +00:00
idCVar r_showShadowMaps ( " r_showShadowMaps " , " 0 " , CVAR_RENDERER | CVAR_BOOL | CVAR_NEW , " " ) ;
idCVar r_showShadowMapLODs ( " r_showShadowMapLODs " , " 0 " , CVAR_RENDERER | CVAR_INTEGER | CVAR_NEW , " " ) ;
2014-05-10 12:40:01 +00:00
// RB end
2012-11-26 18:58:24 +00:00
idCVar r_useEntityCallbacks ( " r_useEntityCallbacks " , " 1 " , CVAR_RENDERER | CVAR_BOOL , " if 0, issue the callback immediately at update time, rather than defering " ) ;
2012-11-28 15:47:07 +00:00
idCVar r_showSkel ( " r_showSkel " , " 0 " , CVAR_RENDERER | CVAR_INTEGER , " draw the skeleton when model animates, 1 = draw model with skeleton, 2 = draw skeleton only " , 0 , 2 , idCmdSystem : : ArgCompletion_Integer < 0 , 2 > ) ;
2012-11-26 18:58:24 +00:00
idCVar r_jointNameScale ( " r_jointNameScale " , " 0.02 " , CVAR_RENDERER | CVAR_FLOAT , " size of joint names when r_showskel is set to 1 " ) ;
idCVar r_jointNameOffset ( " r_jointNameOffset " , " 0.5 " , CVAR_RENDERER | CVAR_FLOAT , " offset of joint names when r_showskel is set to 1 " ) ;
idCVar r_debugLineDepthTest ( " r_debugLineDepthTest " , " 0 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL , " perform depth test on debug lines " ) ;
idCVar r_debugLineWidth ( " r_debugLineWidth " , " 1 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL , " width of debug lines " ) ;
idCVar r_debugArrowStep ( " r_debugArrowStep " , " 120 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER , " step size of arrow cone line rotation in degrees " , 0 , 120 ) ;
idCVar r_debugPolygonFilled ( " r_debugPolygonFilled " , " 1 " , CVAR_RENDERER | CVAR_BOOL , " draw a filled polygon " ) ;
idCVar r_materialOverride ( " r_materialOverride " , " " , CVAR_RENDERER , " overrides all materials " , idCmdSystem : : ArgCompletion_Decl < DECL_MATERIAL > ) ;
idCVar r_debugRenderToTexture ( " r_debugRenderToTexture " , " 0 " , CVAR_RENDERER | CVAR_INTEGER , " " ) ;
idCVar stereoRender_enable ( " stereoRender_enable " , " 0 " , CVAR_INTEGER | CVAR_ARCHIVE , " 1 = side-by-side compressed, 2 = top and bottom compressed, 3 = side-by-side, 4 = 720 frame packed, 5 = interlaced, 6 = OpenGL quad buffer " ) ;
idCVar stereoRender_swapEyes ( " stereoRender_swapEyes " , " 0 " , CVAR_BOOL | CVAR_ARCHIVE , " reverse eye adjustments " ) ;
idCVar stereoRender_deGhost ( " stereoRender_deGhost " , " 0.05 " , CVAR_FLOAT | CVAR_ARCHIVE , " subtract from opposite eye to reduce ghosting " ) ;
2024-07-10 18:33:20 +00:00
idCVar r_useVirtualScreenResolution ( " r_useVirtualScreenResolution " , " 0 " , CVAR_RENDERER | CVAR_BOOL | CVAR_ARCHIVE | CVAR_NEW , " do 2D rendering at 640x480 and stretch to the current resolution " ) ;
2012-11-26 18:58:24 +00:00
2014-05-10 12:40:01 +00:00
// RB: shadow mapping parameters
2024-07-10 18:33:20 +00:00
idCVar r_useShadowAtlas ( " r_useShadowAtlas " , " 1 " , CVAR_RENDERER | CVAR_INTEGER | CVAR_NEW , " " ) ;
idCVar r_shadowMapAtlasSize ( " r_shadowMapAtlasSize " , " 8192 " , CVAR_RENDERER | CVAR_INTEGER | CVAR_ROM | CVAR_NEW , " size of the shadowmap atlas " ) ;
idCVar r_shadowMapFrustumFOV ( " r_shadowMapFrustumFOV " , " 92 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " oversize FOV for point light side matching " ) ;
idCVar r_shadowMapSingleSide ( " r_shadowMapSingleSide " , " -1 " , CVAR_RENDERER | CVAR_INTEGER | CVAR_NEW , " only draw a single side (0-5) of point lights " ) ;
idCVar r_shadowMapImageSize ( " r_shadowMapImageSize " , " 1024 " , CVAR_RENDERER | CVAR_INTEGER | CVAR_NEW , " " , 128 , 2048 ) ;
idCVar r_shadowMapJitterScale ( " r_shadowMapJitterScale " , " 2.5 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " scale factor for jitter offset " ) ;
//idCVar r_shadowMapBiasScale( "r_shadowMapBiasScale", "0.0001", CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW, "scale factor for jitter bias" );
idCVar r_shadowMapRandomizeJitter ( " r_shadowMapRandomizeJitter " , " 1 " , CVAR_RENDERER | CVAR_BOOL | CVAR_NEW , " randomly offset jitter texture each draw " ) ;
idCVar r_shadowMapSamples ( " r_shadowMapSamples " , " 16 " , CVAR_RENDERER | CVAR_INTEGER | CVAR_NEW , " 1, 4, 12 or 16 " , 1 , 64 ) ;
idCVar r_shadowMapSplits ( " r_shadowMapSplits " , " 3 " , CVAR_RENDERER | CVAR_INTEGER | CVAR_NEW , " number of splits for cascaded shadow mapping with parallel lights " , 0 , 4 ) ;
idCVar r_shadowMapSplitWeight ( " r_shadowMapSplitWeight " , " 0.9 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " " ) ;
idCVar r_shadowMapLodScale ( " r_shadowMapLodScale " , " 1.4 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " " ) ;
idCVar r_shadowMapLodBias ( " r_shadowMapLodBias " , " 0 " , CVAR_RENDERER | CVAR_INTEGER | CVAR_NEW , " " ) ;
idCVar r_shadowMapPolygonFactor ( " r_shadowMapPolygonFactor " , " 2 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " polygonOffset factor for drawing shadow buffer " ) ;
idCVar r_shadowMapPolygonOffset ( " r_shadowMapPolygonOffset " , " 3000 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " polygonOffset units for drawing shadow buffer " ) ;
idCVar r_shadowMapOccluderFacing ( " r_shadowMapOccluderFacing " , " 2 " , CVAR_RENDERER | CVAR_INTEGER | CVAR_NEW , " 0 = front faces, 1 = back faces, 2 = twosided " ) ;
idCVar r_shadowMapRegularDepthBiasScale ( " r_shadowMapRegularDepthBiasScale " , " 0.999 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " shadowmap bias to fight shadow acne for point and spot lights " ) ;
idCVar r_shadowMapSunDepthBiasScale ( " r_shadowMapSunDepthBiasScale " , " 0.999991 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " shadowmap bias to fight shadow acne for cascaded shadow mapping with parallel lights " ) ;
2015-12-20 11:28:46 +00:00
// RB: HDR parameters
2024-07-10 18:33:20 +00:00
idCVar r_hdrAutoExposure ( " r_hdrAutoExposure " , " 0 " , CVAR_RENDERER | CVAR_BOOL | CVAR_NEW , " EXPENSIVE: enables adapative HDR tone mapping otherwise the exposure is derived by r_exposure " ) ;
idCVar r_hdrAdaptionRate ( " r_hdrAdaptionRate " , " 1 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " The rate of adapting the hdr exposure value`. Defaulted to a second. " ) ;
idCVar r_hdrMinLuminance ( " r_hdrMinLuminance " , " 0.02 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " " ) ;
idCVar r_hdrMaxLuminance ( " r_hdrMaxLuminance " , " 0.5 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " " ) ;
idCVar r_hdrKey ( " r_hdrKey " , " 0.015 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " magic exposure key that works well with Doom 3 maps " ) ;
idCVar r_hdrContrastDynamicThreshold ( " r_hdrContrastDynamicThreshold " , " 2 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " if auto exposure is on, all pixels brighter than this cause HDR bloom glares " ) ;
idCVar r_hdrContrastStaticThreshold ( " r_hdrContrastStaticThreshold " , " 3 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " if auto exposure is off, all pixels brighter than this cause HDR bloom glares " ) ;
idCVar r_hdrContrastOffset ( " r_hdrContrastOffset " , " 100 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " " ) ;
idCVar r_hdrGlarePasses ( " r_hdrGlarePasses " , " 8 " , CVAR_RENDERER | CVAR_INTEGER | CVAR_NEW , " how many times the bloom blur is rendered offscreen. number should be even " ) ;
idCVar r_hdrDebug ( " r_hdrDebug " , " 0 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " show scene luminance as heat map " ) ;
2015-12-20 11:28:46 +00:00
2024-07-10 18:33:20 +00:00
idCVar r_ldrContrastThreshold ( " r_ldrContrastThreshold " , " 1.1 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " " ) ;
idCVar r_ldrContrastOffset ( " r_ldrContrastOffset " , " 3 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " " ) ;
2015-12-23 12:53:21 +00:00
2024-07-10 18:33:20 +00:00
idCVar r_useFilmicPostFX ( " r_useFilmicPostFX " , " 1 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL | CVAR_NEW , " filmic look with chromatic abberation and film grain " ) ;
2019-11-11 19:07:33 +00:00
2024-07-10 18:33:20 +00:00
idCVar r_forceAmbient ( " r_forceAmbient " , " 0.5 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_FLOAT | CVAR_NEW , " render additional ambient pass to make the game less dark " , 0.0f , 1.0f ) ;
2016-01-10 16:20:38 +00:00
2024-07-10 18:33:20 +00:00
idCVar r_useSSAO ( " r_useSSAO " , " 1 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL | CVAR_NEW , " use screen space ambient occlusion to darken corners " ) ;
idCVar r_ssaoDebug ( " r_ssaoDebug " , " 0 " , CVAR_RENDERER | CVAR_INTEGER | CVAR_NEW , " " ) ;
idCVar r_ssaoFiltering ( " r_ssaoFiltering " , " 0 " , CVAR_RENDERER | CVAR_BOOL | CVAR_NEW , " " ) ;
idCVar r_useHierarchicalDepthBuffer ( " r_useHierarchicalDepthBuffer " , " 1 " , CVAR_RENDERER | CVAR_BOOL | CVAR_NEW , " " ) ;
2016-01-13 23:59:41 +00:00
2024-07-10 18:33:20 +00:00
idCVar r_pbrDebug ( " r_pbrDebug " , " 0 " , CVAR_RENDERER | CVAR_INTEGER | CVAR_NEW , " show which materials have PBR support (green = PBR, red = oldschool D3) " ) ;
idCVar r_showViewEnvprobes ( " r_showViewEnvprobes " , " 0 " , CVAR_RENDERER | CVAR_INTEGER | CVAR_NEW , " 1 = displays the bounding boxes of all view environment probes, 2 = show irradiance " ) ;
idCVar r_showLightGrid ( " r_showLightGrid " , " 0 " , CVAR_RENDERER | CVAR_INTEGER | CVAR_NEW , " show Quake 3 style light grid points " ) ;
2019-11-22 17:25:33 +00:00
2024-07-10 18:33:20 +00:00
idCVar r_useLightGrid ( " r_useLightGrid " , " 1 " , CVAR_RENDERER | CVAR_BOOL | CVAR_NEW , " " ) ;
2019-11-22 17:25:33 +00:00
2024-07-10 18:33:20 +00:00
idCVar r_exposure ( " r_exposure " , " 0.5 " , CVAR_ARCHIVE | CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " HDR exposure or LDR brightness [-4.0 .. 4.0] " , - 4.0f , 4.0f ) ;
2022-04-12 16:15:48 +00:00
2024-12-05 21:31:23 +00:00
idCVar r_useSSR ( " r_useSSR " , " 1 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL | CVAR_NEW , " " ) ;
2024-12-06 16:09:15 +00:00
idCVar r_ssrJitter ( " r_ssrJitter " , " 0 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " " ) ;
2024-12-05 21:31:23 +00:00
idCVar r_ssrMaxDistance ( " r_ssrMaxDistance " , " 100 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " In meters " ) ;
idCVar r_ssrMaxSteps ( " r_ssrMaxSteps " , " 100 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " " ) ;
idCVar r_ssrStride ( " r_ssrStride " , " 12 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " " ) ;
idCVar r_ssrZThickness ( " r_ssrZThickness " , " 2 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " " ) ;
2024-07-10 18:33:20 +00:00
idCVar r_useTemporalAA ( " r_useTemporalAA " , " 1 " , CVAR_RENDERER | CVAR_BOOL | CVAR_NEW , " only disable for debugging " ) ;
2024-10-23 13:41:42 +00:00
idCVar r_taaJitter ( " r_taaJitter " , " 1 " , CVAR_RENDERER | CVAR_INTEGER | CVAR_NEW , " 0: None, 1: MSAA, 2: Halton, 3: R2 Sequence, 4: White Noise " ) ;
2024-07-10 18:33:20 +00:00
idCVar r_taaEnableHistoryClamping ( " r_taaEnableHistoryClamping " , " 1 " , CVAR_RENDERER | CVAR_BOOL | CVAR_NEW , " " ) ;
idCVar r_taaClampingFactor ( " r_taaClampingFactor " , " 1.0 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " " ) ;
idCVar r_taaNewFrameWeight ( " r_taaNewFrameWeight " , " 0.1 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " " ) ;
idCVar r_taaMaxRadiance ( " r_taaMaxRadiance " , " 10000 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " " ) ;
idCVar r_taaMotionVectors ( " r_taaMotionVectors " , " 1 " , CVAR_RENDERER | CVAR_BOOL | CVAR_NEW , " " ) ;
2023-12-28 13:39:59 +00:00
2024-07-31 21:52:01 +00:00
idCVar r_useCRTPostFX ( " r_useCRTPostFX " , " 0 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER | CVAR_NEW , " RetroArch CRT shader: 1 = Matthias CRT, 1 = New Pixie, 2 = Zfast " , 0 , 3 ) ;
2024-07-10 18:33:20 +00:00
idCVar r_crtCurvature ( " r_crtCurvature " , " 2 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " rounded borders " ) ;
idCVar r_crtVignette ( " r_crtVignette " , " 0.8 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " fading into the borders " ) ;
2023-12-30 13:10:07 +00:00
2024-07-10 18:33:20 +00:00
idCVar r_retroDitherScale ( " r_retroDitherScale " , " 0.3 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " " ) ;
2024-01-11 21:06:55 +00:00
2024-07-31 16:11:43 +00:00
idCVar r_renderMode ( " r_renderMode " , " 0 " , CVAR_RENDERER | CVAR_ARCHIVE | CVAR_INTEGER | CVAR_NEW , " 0 = Doom, 1 = Commodore 64, 2 = Commodore 64 Highres, 3 = Amstrad CPC 6128, 4 = Amstrad CPC 6128 Highres, 5 = Gameboy, 6 = Gameboy Highres, 7 = NES, 8 = NES Highres, 9 = Sega Genesis, 10 = Sega Genesis Highres, 11 = Sony PSX " , 0 , 11 ) ;
2024-01-08 17:00:04 +00:00
2024-07-26 15:50:06 +00:00
idCVar r_psxVertexJitter ( " r_psxVertexJitter " , " 0.5 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " " , 0.0f , 0.75f ) ;
2024-08-17 16:37:50 +00:00
idCVar r_psxAffineTextures ( " r_psxAffineTextures " , " 1 " , CVAR_RENDERER | CVAR_FLOAT | CVAR_NEW , " " ) ;
2024-08-22 20:05:47 +00:00
2024-10-15 18:38:09 +00:00
idCVar r_useMaskedOcclusionCulling ( " r_useMaskedOcclusionCulling " , " 1 " , CVAR_RENDERER | CVAR_BOOL | CVAR_NOCHEAT | CVAR_NEW , " SIMD optimized software culling by Intel " ) ;
2014-05-10 12:40:01 +00:00
// RB end
2021-03-14 14:59:02 +00:00
const char * fileExten [ 4 ] = { " tga " , " png " , " jpg " , " exr " } ;
2016-06-14 08:33:50 +00:00
const char * envDirection [ 6 ] = { " _px " , " _nx " , " _py " , " _ny " , " _pz " , " _nz " } ;
2014-08-23 22:10:50 +00:00
const char * skyDirection [ 6 ] = { " _forward " , " _back " , " _left " , " _right " , " _up " , " _down " } ;
2023-12-07 23:16:11 +00:00
DeviceManager * deviceManager = NULL ;
2012-11-26 18:58:24 +00:00
2022-04-19 19:56:30 +00:00
2024-01-03 14:54:58 +00:00
bool R_UsePixelatedLook ( )
{
return ( r_renderMode . GetInteger ( ) = = RENDERMODE_PSX ) | | image_pixelLook . GetBool ( ) ;
}
2022-04-19 19:56:30 +00:00
bool R_UseTemporalAA ( )
{
if ( ! r_useTemporalAA . GetBool ( ) )
{
return false ;
}
2024-11-26 20:18:42 +00:00
if ( r_renderMode . GetInteger ( ) ! = RENDERMODE_DOOM )
2024-07-26 12:46:14 +00:00
{
return false ;
}
2022-04-19 19:56:30 +00:00
switch ( r_antiAliasing . GetInteger ( ) )
{
case ANTI_ALIASING_TAA :
return true ;
2022-05-29 13:51:07 +00:00
# if ID_MSAA
2022-04-19 19:56:30 +00:00
case ANTI_ALIASING_TAA_SMAA_1X :
return true ;
2022-05-29 13:51:07 +00:00
# endif
2022-04-19 19:56:30 +00:00
default :
return false ;
}
}
uint R_GetMSAASamples ( )
{
2022-05-29 13:51:07 +00:00
# if ID_MSAA
2022-04-19 19:56:30 +00:00
switch ( r_antiAliasing . GetInteger ( ) )
{
case ANTI_ALIASING_MSAA_2X :
return 2 ;
case ANTI_ALIASING_MSAA_4X :
return 4 ;
default :
return 1 ;
}
2022-05-29 13:51:07 +00:00
# else
return 1 ;
# endif
2022-04-19 19:56:30 +00:00
}
2012-11-26 18:58:24 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = =
R_SetNewMode
2023-03-15 03:05:00 +00:00
r_fullScreen - 2 borderless fullscreen on current monitor at desktop resolution
2012-11-26 18:58:24 +00:00
r_fullScreen - 1 borderless window at exact desktop coordinates
r_fullScreen 0 bordered window at exact desktop coordinates
r_fullScreen 1 fullscreen on monitor 1 at r_vidMode
r_fullScreen 2 fullscreen on monitor 2 at r_vidMode
. . .
r_vidMode - 1 use r_customWidth / r_customHeight , even if they don ' t appear on the mode list
r_vidMode 0 use first mode returned by EnumDisplaySettings ( )
r_vidMode 1 use second mode returned by EnumDisplaySettings ( )
. . .
r_displayRefresh 0 don ' t specify refresh
r_displayRefresh 70 specify 70 hz , etc
= = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void R_SetNewMode ( const bool fullInit )
{
2012-11-26 18:58:24 +00:00
// try up to three different configurations
2019-11-11 19:27:44 +00:00
2024-11-26 20:18:42 +00:00
for ( int i = 0 ; i < 3 ; i + + )
2012-11-28 15:47:07 +00:00
{
2024-11-26 20:18:42 +00:00
if ( i = = 0 /*&& vr_enable.GetInteger() != STEREO3D_QUAD_BUFFER*/ )
2012-11-28 15:47:07 +00:00
{
2012-11-26 18:58:24 +00:00
continue ; // don't even try for a stereo mode
}
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
glimpParms_t parms ;
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
if ( r_fullscreen . GetInteger ( ) < = 0 )
{
2012-11-26 18:58:24 +00:00
// use explicit position / size for window
parms . x = r_windowX . GetInteger ( ) ;
parms . y = r_windowY . GetInteger ( ) ;
parms . width = r_windowWidth . GetInteger ( ) ;
parms . height = r_windowHeight . GetInteger ( ) ;
2023-03-15 03:05:00 +00:00
// may still be -1 or -2 to force a borderless window
2012-11-26 18:58:24 +00:00
parms . fullScreen = r_fullscreen . GetInteger ( ) ;
parms . displayHz = 0 ; // ignored
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
// get the mode list for this monitor
idList < vidMode_t > modeList ;
2012-11-28 15:47:07 +00:00
if ( ! R_GetModeListForDisplay ( r_fullscreen . GetInteger ( ) - 1 , modeList ) )
{
2023-03-15 03:05:00 +00:00
idLib : : Printf ( " r_fullscreen reset from %i to 1 because mode list failed. \n " , r_fullscreen . GetInteger ( ) ) ;
2012-11-26 18:58:24 +00:00
r_fullscreen . SetInteger ( 1 ) ;
2012-11-28 15:47:07 +00:00
R_GetModeListForDisplay ( r_fullscreen . GetInteger ( ) - 1 , modeList ) ;
2012-11-26 18:58:24 +00:00
}
2019-12-30 20:20:15 +00:00
2012-11-28 15:47:07 +00:00
if ( modeList . Num ( ) < 1 )
{
2023-03-15 03:05:00 +00:00
idLib : : Printf ( " Going to safe mode because mode list failed. \n " ) ;
2012-11-26 18:58:24 +00:00
goto safeMode ;
}
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
parms . x = 0 ; // ignored
parms . y = 0 ; // ignored
parms . fullScreen = r_fullscreen . GetInteger ( ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
// set the parameters we are trying
2012-11-28 15:47:07 +00:00
if ( r_vidMode . GetInteger ( ) < 0 )
{
2012-11-26 18:58:24 +00:00
// try forcing a specific mode, even if it isn't on the list
parms . width = r_customWidth . GetInteger ( ) ;
parms . height = r_customHeight . GetInteger ( ) ;
parms . displayHz = r_displayRefresh . GetInteger ( ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2013-09-18 02:39:31 +00:00
if ( r_vidMode . GetInteger ( ) > = modeList . Num ( ) )
2012-11-28 15:47:07 +00:00
{
2012-11-26 18:58:24 +00:00
idLib : : Printf ( " r_vidMode reset from %i to 0. \n " , r_vidMode . GetInteger ( ) ) ;
r_vidMode . SetInteger ( 0 ) ;
}
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
parms . width = modeList [ r_vidMode . GetInteger ( ) ] . width ;
parms . height = modeList [ r_vidMode . GetInteger ( ) ] . height ;
parms . displayHz = modeList [ r_vidMode . GetInteger ( ) ] . displayHz ;
}
}
2019-11-11 19:27:44 +00:00
2015-12-30 11:07:24 +00:00
switch ( r_antiAliasing . GetInteger ( ) )
{
2022-05-29 13:51:07 +00:00
# if ID_MSAA
2015-12-30 11:07:24 +00:00
case ANTI_ALIASING_MSAA_2X :
parms . multiSamples = 2 ;
break ;
case ANTI_ALIASING_MSAA_4X :
parms . multiSamples = 4 ;
break ;
2023-06-23 20:30:48 +00:00
# elif defined( _MSC_VER ) // SRS: #pragma warning is MSVC specific
# pragma warning( push )
# pragma warning( disable : 4065 ) // C4065: switch statement contains 'default' but no 'case'
2022-05-29 13:51:07 +00:00
# endif
2019-11-11 19:27:44 +00:00
2015-12-30 11:07:24 +00:00
default :
2022-04-13 20:05:05 +00:00
parms . multiSamples = 1 ;
2015-12-30 11:07:24 +00:00
break ;
}
2023-06-23 20:30:48 +00:00
# if !ID_MSAA && defined( _MSC_VER )
# pragma warning( pop )
# endif
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
if ( fullInit )
{
2012-11-26 18:58:24 +00:00
// create the context as well as setting up the window
2022-02-21 20:26:36 +00:00
2022-10-22 01:51:26 +00:00
# if defined( VULKAN_USE_PLATFORM_SDL )
2020-03-22 11:23:52 +00:00
if ( VKimp_Init ( parms ) )
2019-12-30 20:20:15 +00:00
# else
2020-03-22 11:23:52 +00:00
if ( GLimp_Init ( parms ) )
2019-12-30 20:20:15 +00:00
# endif
2012-11-28 15:47:07 +00:00
{
2024-11-26 20:18:42 +00:00
ImGuiHook : : Init ( renderSystem - > GetWidth ( ) , renderSystem - > GetHeight ( ) ) ;
2012-11-26 18:58:24 +00:00
break ;
}
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
// just rebuild the window
2022-02-21 18:56:21 +00:00
2022-10-22 01:51:26 +00:00
# if defined( VULKAN_USE_PLATFORM_SDL )
2020-03-22 11:23:52 +00:00
if ( VKimp_SetScreenParms ( parms ) )
2019-12-30 20:20:15 +00:00
# else
2012-11-28 15:47:07 +00:00
if ( GLimp_SetScreenParms ( parms ) )
2019-12-30 20:20:15 +00:00
# endif
2012-11-28 15:47:07 +00:00
{
2022-02-21 18:56:21 +00:00
Framebuffer : : ResizeFramebuffers ( ) ;
2024-11-26 20:18:42 +00:00
ImGuiHook : : NotifyDisplaySizeChanged ( renderSystem - > GetWidth ( ) , renderSystem - > GetHeight ( ) ) ;
2012-11-26 18:58:24 +00:00
break ;
}
}
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
if ( i = = 2 )
{
2024-11-26 20:18:42 +00:00
common - > FatalError ( " Unable to initialize renderer " ) ;
2012-11-26 18:58:24 +00:00
}
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
if ( i = = 0 )
{
2012-11-26 18:58:24 +00:00
// same settings, no stereo
continue ;
}
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
safeMode :
// if we failed, set everything back to "safe mode"
// and try again
r_vidMode . SetInteger ( 0 ) ;
r_fullscreen . SetInteger ( 1 ) ;
r_displayRefresh . SetInteger ( 0 ) ;
2015-12-30 11:07:24 +00:00
r_antiAliasing . SetInteger ( 0 ) ;
2012-11-26 18:58:24 +00:00
}
}
/*
= = = = = = = = = = = = = = = = = = = = =
R_ReloadSurface_f
Reload the material displayed by r_showSurfaceInfo
= = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
static void R_ReloadSurface_f ( const idCmdArgs & args )
{
2012-11-26 18:58:24 +00:00
modelTrace_t mt ;
idVec3 start , end ;
2019-11-11 19:27:44 +00:00
2022-02-21 18:56:21 +00:00
if ( ! tr . primaryView )
{
return ;
}
2012-11-26 18:58:24 +00:00
// start far enough away that we don't hit the player model
start = tr . primaryView - > renderView . vieworg + tr . primaryView - > renderView . viewaxis [ 0 ] * 16 ;
end = start + tr . primaryView - > renderView . viewaxis [ 0 ] * 1000.0f ;
2012-11-28 15:47:07 +00:00
if ( ! tr . primaryWorld - > Trace ( mt , start , end , 0.0f , false ) )
{
2012-11-26 18:58:24 +00:00
return ;
}
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
common - > Printf ( " Reloading %s \n " , mt . material - > GetName ( ) ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
// reload the decl
mt . material - > base - > Reload ( ) ;
2019-11-11 19:27:44 +00:00
2022-02-21 18:56:21 +00:00
nvrhi : : CommandListHandle commandList = deviceManager - > GetDevice ( ) - > createCommandList ( ) ;
commandList - > open ( ) ;
2022-02-21 20:26:36 +00:00
2012-11-26 18:58:24 +00:00
// reload any images used by the decl
2022-02-21 18:56:21 +00:00
mt . material - > ReloadImages ( false , commandList ) ;
2022-02-21 20:26:36 +00:00
2022-02-21 18:56:21 +00:00
commandList - > close ( ) ;
deviceManager - > GetDevice ( ) - > executeCommandList ( commandList ) ;
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = =
R_ListModes_f
= = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
static void R_ListModes_f ( const idCmdArgs & args )
{
for ( int displayNum = 0 ; ; displayNum + + )
{
2012-11-26 18:58:24 +00:00
idList < vidMode_t > modeList ;
2012-11-28 15:47:07 +00:00
if ( ! R_GetModeListForDisplay ( displayNum , modeList ) )
{
2012-11-26 18:58:24 +00:00
break ;
}
2012-11-28 15:47:07 +00:00
for ( int i = 0 ; i < modeList . Num ( ) ; i + + )
{
common - > Printf ( " Monitor %i, mode %3i: %4i x %4i @ %ihz \n " , displayNum + 1 , i , modeList [ i ] . width , modeList [ i ] . height , modeList [ i ] . displayHz ) ;
2012-11-26 18:58:24 +00:00
}
}
}
/*
= = = = = = = = = = = = =
R_TestImage_f
Display the given image centered on the screen .
testimage < number >
testimage < filename >
= = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void R_TestImage_f ( const idCmdArgs & args )
{
2012-11-26 18:58:24 +00:00
int imageNum ;
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
if ( tr . testVideo )
{
2012-11-26 18:58:24 +00:00
delete tr . testVideo ;
tr . testVideo = NULL ;
}
tr . testImage = NULL ;
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
if ( args . Argc ( ) ! = 2 )
{
2012-11-26 18:58:24 +00:00
return ;
}
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
if ( idStr : : IsNumeric ( args . Argv ( 1 ) ) )
{
imageNum = atoi ( args . Argv ( 1 ) ) ;
if ( imageNum > = 0 & & imageNum < globalImages - > images . Num ( ) )
{
2012-11-26 18:58:24 +00:00
tr . testImage = globalImages - > images [ imageNum ] ;
}
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
tr . testImage = globalImages - > ImageFromFile ( args . Argv ( 1 ) , TF_DEFAULT , TR_REPEAT , TD_DEFAULT ) ;
}
}
/*
= = = = = = = = = = = = =
R_TestVideo_f
Plays the cinematic file in a testImage
= = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void R_TestVideo_f ( const idCmdArgs & args )
{
if ( tr . testVideo )
{
2012-11-26 18:58:24 +00:00
delete tr . testVideo ;
tr . testVideo = NULL ;
}
tr . testImage = NULL ;
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
if ( args . Argc ( ) < 2 )
{
2012-11-26 18:58:24 +00:00
return ;
}
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
tr . testImage = globalImages - > ImageFromFile ( " _scratch " , TF_DEFAULT , TR_REPEAT , TD_DEFAULT ) ;
tr . testVideo = idCinematic : : Alloc ( ) ;
2022-12-20 07:06:07 +00:00
// SRS - make sure we have a valid bink, ffmpeg, or RoQ video file, otherwise delete testVideo and return
// SRS - no need to call ImageForTime() here, playback is handled within idRenderBackend::DBG_TestImage()
if ( ! tr . testVideo - > InitFromFile ( args . Argv ( 1 ) , true , NULL ) )
2012-11-28 15:47:07 +00:00
{
2012-11-26 18:58:24 +00:00
delete tr . testVideo ;
tr . testVideo = NULL ;
tr . testImage = NULL ;
return ;
}
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
// try to play the matching wav file
idStr wavString = args . Argv ( ( args . Argc ( ) = = 2 ) ? 1 : 2 ) ;
wavString . StripFileExtension ( ) ;
wavString = wavString + " .wav " ;
common - > SW ( ) - > PlayShaderDirectly ( wavString . c_str ( ) ) ;
}
2012-11-28 15:47:07 +00:00
static int R_QsortSurfaceAreas ( const void * a , const void * b )
{
const idMaterial * ea , * eb ;
2012-11-26 18:58:24 +00:00
int ac , bc ;
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
ea = * ( idMaterial * * ) a ;
if ( ! ea - > EverReferenced ( ) )
{
2012-11-26 18:58:24 +00:00
ac = 0 ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
ac = ea - > GetSurfaceArea ( ) ;
}
2012-11-28 15:47:07 +00:00
eb = * ( idMaterial * * ) b ;
if ( ! eb - > EverReferenced ( ) )
{
2012-11-26 18:58:24 +00:00
bc = 0 ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
bc = eb - > GetSurfaceArea ( ) ;
}
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
if ( ac < bc )
{
2012-11-26 18:58:24 +00:00
return - 1 ;
}
2012-11-28 15:47:07 +00:00
if ( ac > bc )
{
2012-11-26 18:58:24 +00:00
return 1 ;
}
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
return idStr : : Icmp ( ea - > GetName ( ) , eb - > GetName ( ) ) ;
}
/*
= = = = = = = = = = = = = = = = = = =
R_ReportSurfaceAreas_f
Prints a list of the materials sorted by surface area
= = = = = = = = = = = = = = = = = = =
*/
# pragma warning( disable: 6385 ) // This is simply to get pass a false defect for /analyze -- if you can figure out a better way, please let Shawn know...
2012-11-28 15:47:07 +00:00
void R_ReportSurfaceAreas_f ( const idCmdArgs & args )
{
2012-11-26 18:58:24 +00:00
unsigned int i ;
2012-11-28 15:47:07 +00:00
idMaterial * * list ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
const unsigned int count = declManager - > GetNumDecls ( DECL_MATERIAL ) ;
2012-11-28 15:47:07 +00:00
if ( count = = 0 )
{
2012-11-26 18:58:24 +00:00
return ;
}
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
list = ( idMaterial * * ) _alloca ( count * sizeof ( * list ) ) ;
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
for ( i = 0 ; i < count ; i + + )
{
list [ i ] = ( idMaterial * ) declManager - > DeclByIndex ( DECL_MATERIAL , i , false ) ;
2012-11-26 18:58:24 +00:00
}
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
qsort ( list , count , sizeof ( list [ 0 ] ) , R_QsortSurfaceAreas ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
// skip over ones with 0 area
2012-11-28 15:47:07 +00:00
for ( i = 0 ; i < count ; i + + )
{
if ( list [ i ] - > GetSurfaceArea ( ) > 0 )
{
2012-11-26 18:58:24 +00:00
break ;
}
}
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
for ( ; i < count ; i + + )
{
2012-11-26 18:58:24 +00:00
// report size in "editor blocks"
int blocks = list [ i ] - > GetSurfaceArea ( ) / 4096.0 ;
common - > Printf ( " %7i %s \n " , blocks , list [ i ] - > GetName ( ) ) ;
}
}
# pragma warning( default: 6385 )
2012-11-28 15:47:07 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
SCREEN SHOTS
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-26 18:58:24 +00:00
2022-04-16 14:29:17 +00:00
bool R_ReadPixelsRGB8 ( nvrhi : : IDevice * device , CommonRenderPasses * pPasses , nvrhi : : ITexture * texture , nvrhi : : ResourceStates textureState , const char * fullname )
2012-11-28 15:47:07 +00:00
{
2022-04-16 14:29:17 +00:00
nvrhi : : TextureDesc desc = texture - > getDesc ( ) ;
nvrhi : : TextureHandle tempTexture ;
nvrhi : : FramebufferHandle tempFramebuffer ;
2019-11-11 19:27:44 +00:00
2022-04-16 14:29:17 +00:00
nvrhi : : CommandListHandle commandList = device - > createCommandList ( ) ;
commandList - > open ( ) ;
2021-03-14 14:59:02 +00:00
2022-04-16 14:29:17 +00:00
if ( textureState ! = nvrhi : : ResourceStates : : Unknown )
2021-03-14 14:59:02 +00:00
{
2022-04-16 14:29:17 +00:00
commandList - > beginTrackingTextureState ( texture , nvrhi : : TextureSubresourceSet ( 0 , 1 , 0 , 1 ) , textureState ) ;
2021-03-14 14:59:02 +00:00
}
2019-11-11 19:27:44 +00:00
2022-04-16 14:29:17 +00:00
switch ( desc . format )
2019-11-11 19:27:44 +00:00
{
2022-04-16 14:29:17 +00:00
case nvrhi : : Format : : RGBA8_UNORM :
case nvrhi : : Format : : SRGBA8_UNORM :
tempTexture = texture ;
break ;
default :
desc . format = nvrhi : : Format : : SRGBA8_UNORM ;
desc . isRenderTarget = true ;
desc . initialState = nvrhi : : ResourceStates : : RenderTarget ;
desc . keepInitialState = true ;
tempTexture = device - > createTexture ( desc ) ;
tempFramebuffer = device - > createFramebuffer ( nvrhi : : FramebufferDesc ( ) . addColorAttachment ( tempTexture ) ) ;
pPasses - > BlitTexture ( commandList , tempFramebuffer , texture ) ;
2019-11-11 19:27:44 +00:00
}
2022-04-16 14:29:17 +00:00
nvrhi : : StagingTextureHandle stagingTexture = device - > createStagingTexture ( desc , nvrhi : : CpuAccessMode : : Read ) ;
commandList - > copyTexture ( stagingTexture , nvrhi : : TextureSlice ( ) , tempTexture , nvrhi : : TextureSlice ( ) ) ;
if ( textureState ! = nvrhi : : ResourceStates : : Unknown )
2019-11-11 19:27:44 +00:00
{
2022-04-16 14:29:17 +00:00
commandList - > setTextureState ( texture , nvrhi : : TextureSubresourceSet ( 0 , 1 , 0 , 1 ) , textureState ) ;
commandList - > commitBarriers ( ) ;
2019-11-11 19:27:44 +00:00
}
2022-04-16 14:29:17 +00:00
commandList - > close ( ) ;
device - > executeCommandList ( commandList ) ;
2019-11-11 19:27:44 +00:00
2022-04-16 14:29:17 +00:00
size_t rowPitch = 0 ;
void * pData = device - > mapStagingTexture ( stagingTexture , nvrhi : : TextureSlice ( ) , nvrhi : : CpuAccessMode : : Read , & rowPitch ) ;
2021-04-13 15:51:16 +00:00
2022-04-16 14:29:17 +00:00
if ( ! pData )
2021-04-13 15:51:16 +00:00
{
2022-04-16 14:29:17 +00:00
return false ;
2021-04-13 15:51:16 +00:00
}
2019-11-11 19:27:44 +00:00
2022-04-16 14:29:17 +00:00
uint32_t * newData = nullptr ;
2019-11-11 19:27:44 +00:00
2022-04-16 14:29:17 +00:00
if ( rowPitch ! = desc . width * 4 )
2012-11-28 15:47:07 +00:00
{
2022-04-16 14:29:17 +00:00
newData = new uint32_t [ desc . width * desc . height ] ;
2019-11-11 19:27:44 +00:00
2022-04-16 14:29:17 +00:00
for ( uint32_t row = 0 ; row < desc . height ; row + + )
{
memcpy ( newData + row * desc . width , static_cast < char * > ( pData ) + row * rowPitch , desc . width * sizeof ( uint32_t ) ) ;
}
2021-03-22 19:45:25 +00:00
2022-04-16 14:29:17 +00:00
pData = newData ;
}
2021-03-14 14:59:02 +00:00
2022-04-16 14:29:17 +00:00
byte * data = static_cast < byte * > ( pData ) ;
2021-03-14 14:59:02 +00:00
2022-07-03 12:16:04 +00:00
#if 0
// fill with red for debugging
for ( int i = 0 ; i < ( desc . width * desc . height ) ; i + + )
{
data [ i * 4 + 0 ] = 255 ;
data [ i * 4 + 1 ] = 0 ;
data [ i * 4 + 2 ] = 0 ;
}
# endif
// fix alpha
2023-06-23 20:30:48 +00:00
for ( uint32_t i = 0 ; i < ( desc . width * desc . height ) ; i + + )
2022-04-16 14:29:17 +00:00
{
data [ i * 4 + 3 ] = 0xff ;
2012-11-26 18:58:24 +00:00
}
2019-11-11 19:27:44 +00:00
2023-03-05 13:51:34 +00:00
// SRS - Save screen shots to fs_savepath on macOS (i.e. don't save into an app bundle's basepath)
# if defined(__APPLE__)
2024-06-22 22:08:30 +00:00
R_WritePNG ( fullname , static_cast < byte * > ( pData ) , 4 , desc . width , desc . height , " fs_savepath " ) ;
2023-03-05 13:51:34 +00:00
# else
2024-06-19 16:21:42 +00:00
R_WritePNG ( fullname , static_cast < byte * > ( pData ) , 4 , desc . width , desc . height , " fs_basepath " ) ;
2023-03-05 13:51:34 +00:00
# endif
2019-11-11 19:27:44 +00:00
2022-04-16 14:29:17 +00:00
if ( newData )
2021-04-13 15:51:16 +00:00
{
2022-04-16 14:29:17 +00:00
delete [ ] newData ;
newData = nullptr ;
2021-04-13 15:51:16 +00:00
}
2019-11-11 19:27:44 +00:00
2022-04-16 14:29:17 +00:00
device - > unmapStagingTexture ( stagingTexture ) ;
2022-04-23 14:34:22 +00:00
return true ;
}
2022-07-03 12:16:04 +00:00
bool R_ReadPixelsRGB16F ( nvrhi : : IDevice * device , CommonRenderPasses * pPasses , nvrhi : : ITexture * texture , nvrhi : : ResourceStates textureState , byte * * pic , int picWidth , int picHeight )
2022-04-23 14:34:22 +00:00
{
nvrhi : : TextureDesc desc = texture - > getDesc ( ) ;
nvrhi : : TextureHandle tempTexture ;
nvrhi : : FramebufferHandle tempFramebuffer ;
2022-07-03 12:16:04 +00:00
#if 0
2022-04-23 14:34:22 +00:00
if ( desc . width ! = picWidth | | desc . height ! = picHeight )
{
return false ;
}
2022-07-03 12:16:04 +00:00
# endif
2022-04-23 14:34:22 +00:00
nvrhi : : CommandListHandle commandList = device - > createCommandList ( ) ;
commandList - > open ( ) ;
if ( textureState ! = nvrhi : : ResourceStates : : Unknown )
{
commandList - > beginTrackingTextureState ( texture , nvrhi : : TextureSubresourceSet ( 0 , 1 , 0 , 1 ) , textureState ) ;
}
switch ( desc . format )
{
case nvrhi : : Format : : RGBA16_FLOAT :
tempTexture = texture ;
break ;
default :
desc . format = nvrhi : : Format : : RGBA16_FLOAT ;
desc . isRenderTarget = true ;
desc . initialState = nvrhi : : ResourceStates : : RenderTarget ;
desc . keepInitialState = true ;
tempTexture = device - > createTexture ( desc ) ;
tempFramebuffer = device - > createFramebuffer ( nvrhi : : FramebufferDesc ( ) . addColorAttachment ( tempTexture ) ) ;
pPasses - > BlitTexture ( commandList , tempFramebuffer , texture ) ;
}
nvrhi : : StagingTextureHandle stagingTexture = device - > createStagingTexture ( desc , nvrhi : : CpuAccessMode : : Read ) ;
commandList - > copyTexture ( stagingTexture , nvrhi : : TextureSlice ( ) , tempTexture , nvrhi : : TextureSlice ( ) ) ;
if ( textureState ! = nvrhi : : ResourceStates : : Unknown )
{
commandList - > setTextureState ( texture , nvrhi : : TextureSubresourceSet ( 0 , 1 , 0 , 1 ) , textureState ) ;
commandList - > commitBarriers ( ) ;
}
commandList - > close ( ) ;
device - > executeCommandList ( commandList ) ;
size_t rowPitch = 0 ;
void * pData = device - > mapStagingTexture ( stagingTexture , nvrhi : : TextureSlice ( ) , nvrhi : : CpuAccessMode : : Read , & rowPitch ) ;
if ( ! pData )
{
return false ;
}
uint16_t * newData = nullptr ;
if ( rowPitch ! = desc . width * 8 )
{
newData = new uint16_t [ desc . width * desc . height * 2 ] ;
for ( uint32_t row = 0 ; row < desc . height ; row + + )
{
memcpy ( newData + row * desc . width , static_cast < char * > ( pData ) + row * rowPitch , desc . width * sizeof ( uint16_t ) * 4 ) ;
}
pData = newData ;
}
2022-07-03 12:16:04 +00:00
int pix = picWidth * picHeight ;
const int bufferSize = pix * 3 * 2 ;
void * floatRGB16F = R_StaticAlloc ( bufferSize ) ;
* pic = ( byte * ) floatRGB16F ;
2022-04-23 14:34:22 +00:00
// copy from RGBA16F to RGB16F
uint16_t * data = static_cast < uint16_t * > ( pData ) ;
2022-07-03 12:16:04 +00:00
uint16_t * outData = static_cast < uint16_t * > ( floatRGB16F ) ;
2022-09-06 16:39:47 +00:00
#if 0
2022-07-03 12:16:04 +00:00
for ( int i = 0 ; i < ( desc . width * desc . height ) ; i + + )
{
outData [ i * 3 + 0 ] = F32toF16 ( 1 ) ;
outData [ i * 3 + 1 ] = F32toF16 ( 0 ) ;
outData [ i * 3 + 2 ] = F32toF16 ( 0 ) ;
}
2022-09-06 16:39:47 +00:00
# endif
2022-04-23 14:34:22 +00:00
2023-06-23 20:30:48 +00:00
for ( uint32_t i = 0 ; i < ( desc . width * desc . height ) ; i + + )
2022-04-23 14:34:22 +00:00
{
outData [ i * 3 + 0 ] = data [ i * 4 + 0 ] ;
outData [ i * 3 + 1 ] = data [ i * 4 + 1 ] ;
outData [ i * 3 + 2 ] = data [ i * 4 + 2 ] ;
}
2022-09-06 16:39:47 +00:00
// RB: filter out garbage and reset it to black
// this is a rare case but with a high visual impact
bool isCorrupted = false ;
const idVec3 LUMINANCE_LINEAR ( 0.299f , 0.587f , 0.144f ) ;
idVec3 rgb ;
2023-06-23 20:30:48 +00:00
for ( uint32_t i = 0 ; i < ( desc . width * desc . height ) ; i + + )
2022-09-06 16:39:47 +00:00
{
rgb . x = F16toF32 ( outData [ i * 3 + 0 ] ) ;
rgb . y = F16toF32 ( outData [ i * 3 + 1 ] ) ;
rgb . z = F16toF32 ( outData [ i * 3 + 2 ] ) ;
if ( IsNAN ( rgb . x ) | | IsNAN ( rgb . y ) | | IsNAN ( rgb . z ) )
{
isCorrupted = true ;
break ;
}
// captures within the Doom 3 main campaign usually have a luminance of ~ 0.5 - 4.0
// the threshold is a bit higher and might need to be adapted for total conversion content
float luminance = rgb * LUMINANCE_LINEAR ;
2024-09-04 21:04:20 +00:00
if ( luminance > 30.0f )
2022-09-06 16:39:47 +00:00
{
isCorrupted = true ;
break ;
}
}
if ( isCorrupted )
{
2023-06-23 20:30:48 +00:00
for ( uint32_t i = 0 ; i < ( desc . width * desc . height ) ; i + + )
2022-09-06 16:39:47 +00:00
{
outData [ i * 3 + 0 ] = F32toF16 ( 0 ) ;
outData [ i * 3 + 1 ] = F32toF16 ( 0 ) ;
outData [ i * 3 + 2 ] = F32toF16 ( 0 ) ;
}
}
2022-04-23 14:34:22 +00:00
if ( newData )
{
delete [ ] newData ;
newData = nullptr ;
}
device - > unmapStagingTexture ( stagingTexture ) ;
2019-11-11 19:27:44 +00:00
2022-09-06 16:39:47 +00:00
return ( ! isCorrupted ) ;
2012-11-26 18:58:24 +00:00
}
/*
2012-11-28 15:47:07 +00:00
= = = = = = = = = = = = = = = = = =
2012-11-26 18:58:24 +00:00
TakeScreenshot
Move to tr_imagefiles . c . . .
If ref = = NULL , common - > UpdateScreen will be used
2012-11-28 15:47:07 +00:00
= = = = = = = = = = = = = = = = = =
*/
2022-04-16 14:29:17 +00:00
void idRenderSystemLocal : : TakeScreenshot ( int widthIgnored , int heightIgnored , const char * fileName , renderView_t * ref )
2012-11-28 15:47:07 +00:00
{
2012-11-26 18:58:24 +00:00
takingScreenshot = true ;
2019-11-11 19:27:44 +00:00
2022-04-16 14:29:17 +00:00
// make sure the game / draw thread has completed
commonLocal . WaitGameThread ( ) ;
2019-11-11 19:27:44 +00:00
2022-04-16 14:29:17 +00:00
// discard anything currently on the list
tr . SwapCommandBuffers ( NULL , NULL , NULL , NULL , NULL , NULL ) ;
2023-02-23 06:39:28 +00:00
// SRS - Update finishSyncTime so frame-over-frame timers display correctly for screenshots
commonLocal . frameTiming . finishSyncTime = Sys_Microseconds ( ) ;
2022-04-16 14:29:17 +00:00
if ( ref )
2012-11-28 15:47:07 +00:00
{
2022-04-16 14:29:17 +00:00
// ref is only used by envShot, Event_camShot, etc to grab screenshots of things in the world,
// so this omits the hud and other effects
tr . primaryWorld - > RenderScene ( ref ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2022-04-16 14:29:17 +00:00
// build all the draw commands without running a new game tic
commonLocal . Draw ( ) ;
2012-11-26 18:58:24 +00:00
}
2022-04-16 14:29:17 +00:00
// this should exit right after vsync, with the GPU idle and ready to draw
const emptyCommand_t * cmd = tr . SwapCommandBuffers ( NULL , NULL , NULL , NULL , NULL , NULL ) ;
2020-04-13 16:20:45 +00:00
2022-04-16 14:29:17 +00:00
// get the GPU busy with new commands
tr . RenderCommandBuffers ( cmd ) ;
2019-11-11 19:27:44 +00:00
2022-04-16 14:29:17 +00:00
// discard anything currently on the list (this triggers SwapBuffers)
tr . SwapCommandBuffers ( NULL , NULL , NULL , NULL , NULL , NULL ) ;
2019-11-11 19:27:44 +00:00
2022-04-16 14:29:17 +00:00
R_ReadPixelsRGB8 ( deviceManager - > GetDevice ( ) , & tr . backend . GetCommonPasses ( ) , globalImages - > ldrImage - > GetTextureHandle ( ) , nvrhi : : ResourceStates : : RenderTarget , fileName ) ;
// discard anything currently on the list
tr . SwapCommandBuffers ( NULL , NULL , NULL , NULL , NULL , NULL ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
takingScreenshot = false ;
}
2022-04-16 14:29:17 +00:00
// RB: TODO FINISH or REMOVE
2021-04-13 15:51:16 +00:00
byte * idRenderSystemLocal : : CaptureRenderToBuffer ( int width , int height , renderView_t * ref )
{
byte * buffer ;
takingScreenshot = true ;
int pix = width * height ;
2021-05-01 13:59:46 +00:00
//const int bufferSize = pix * 3 * 2;
2021-04-13 15:51:16 +00:00
// HDR only for now
//if( exten == EXR )
{
buffer = ( byte * ) R_StaticAlloc ( pix * 3 * 2 ) ;
}
//else if( exten == PNG )
//{
// buffer = ( byte* )R_StaticAlloc( pix * 3 );
//}
2022-04-16 14:29:17 +00:00
//R_ReadTiledPixels( width, height, buffer, ref );
2021-04-13 15:51:16 +00:00
takingScreenshot = false ;
return buffer ;
}
2012-11-28 15:47:07 +00:00
/*
= = = = = = = = = = = = = = = = = =
2012-11-26 18:58:24 +00:00
R_ScreenshotFilename
Returns a filename with digits appended
if we have saved a previous screenshot , don ' t scan
from the beginning , because recording demo avis can involve
thousands of shots
2012-11-28 15:47:07 +00:00
= = = = = = = = = = = = = = = = = =
*/
void R_ScreenshotFilename ( int & lastNumber , const char * base , idStr & fileName )
{
2012-11-26 18:58:24 +00:00
bool restrict = cvarSystem - > GetCVarBool ( " fs_restrict " ) ;
cvarSystem - > SetCVarBool ( " fs_restrict " , false ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
lastNumber + + ;
2012-11-28 15:47:07 +00:00
if ( lastNumber > 99999 )
{
2012-11-26 18:58:24 +00:00
lastNumber = 99999 ;
}
2012-11-28 15:47:07 +00:00
for ( ; lastNumber < 99999 ; lastNumber + + )
{
2019-11-11 19:27:44 +00:00
2014-05-10 16:15:33 +00:00
// RB: added date to screenshot name
#if 0
2012-11-26 18:58:24 +00:00
int frac = lastNumber ;
2014-05-10 16:15:33 +00:00
int a , b , c , d , e ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
a = frac / 10000 ;
2012-11-28 15:47:07 +00:00
frac - = a * 10000 ;
2012-11-26 18:58:24 +00:00
b = frac / 1000 ;
2012-11-28 15:47:07 +00:00
frac - = b * 1000 ;
2012-11-26 18:58:24 +00:00
c = frac / 100 ;
2012-11-28 15:47:07 +00:00
frac - = c * 100 ;
2012-11-26 18:58:24 +00:00
d = frac / 10 ;
2012-11-28 15:47:07 +00:00
frac - = d * 10 ;
2012-11-26 18:58:24 +00:00
e = frac ;
2019-11-11 19:27:44 +00:00
2014-05-10 16:15:33 +00:00
sprintf ( fileName , " %s%i%i%i%i%i.png " , base , a , b , c , d , e ) ;
# else
time_t aclock ;
time ( & aclock ) ;
struct tm * t = localtime ( & aclock ) ;
2019-11-11 19:27:44 +00:00
2022-04-16 14:29:17 +00:00
sprintf ( fileName , " %s%s-%04d%02d%02d-%02d%02d%02d-%03d.png " , base , " rbdoom-3-bfg " ,
2014-05-10 16:15:33 +00:00
1900 + t - > tm_year , 1 + t - > tm_mon , t - > tm_mday , t - > tm_hour , t - > tm_min , t - > tm_sec , lastNumber ) ;
# endif
// RB end
2012-11-28 15:47:07 +00:00
if ( lastNumber = = 99999 )
{
2012-11-26 18:58:24 +00:00
break ;
}
int len = fileSystem - > ReadFile ( fileName , NULL , NULL ) ;
2012-11-28 15:47:07 +00:00
if ( len < = 0 )
{
2012-11-26 18:58:24 +00:00
break ;
}
// check again...
}
cvarSystem - > SetCVarBool ( " fs_restrict " , restrict ) ;
}
/*
2012-11-28 15:47:07 +00:00
= = = = = = = = = = = = = = = = = =
2012-11-26 18:58:24 +00:00
R_BlendedScreenShot
screenshot
screenshot [ filename ]
screenshot [ width ] [ height ]
2012-11-28 15:47:07 +00:00
= = = = = = = = = = = = = = = = = =
*/
void R_ScreenShot_f ( const idCmdArgs & args )
{
2012-11-26 18:58:24 +00:00
static int lastNumber = 0 ;
idStr checkname ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
int width = renderSystem - > GetWidth ( ) ;
int height = renderSystem - > GetHeight ( ) ;
int blends = 0 ;
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
switch ( args . Argc ( ) )
{
case 1 :
width = renderSystem - > GetWidth ( ) ;
height = renderSystem - > GetHeight ( ) ;
2012-11-26 18:58:24 +00:00
blends = 1 ;
2014-05-10 16:15:33 +00:00
R_ScreenshotFilename ( lastNumber , " screenshots/ " , checkname ) ;
2012-11-28 15:47:07 +00:00
break ;
2022-04-16 14:29:17 +00:00
2012-11-28 15:47:07 +00:00
case 2 :
width = renderSystem - > GetWidth ( ) ;
height = renderSystem - > GetHeight ( ) ;
blends = 1 ;
checkname = args . Argv ( 1 ) ;
break ;
2022-04-16 14:29:17 +00:00
2012-11-28 15:47:07 +00:00
case 3 :
width = atoi ( args . Argv ( 1 ) ) ;
height = atoi ( args . Argv ( 2 ) ) ;
blends = 1 ;
2014-05-10 16:15:33 +00:00
R_ScreenshotFilename ( lastNumber , " screenshots/ " , checkname ) ;
2012-11-28 15:47:07 +00:00
break ;
2022-04-16 14:29:17 +00:00
2012-11-28 15:47:07 +00:00
default :
2022-04-16 14:29:17 +00:00
common - > Printf ( " usage: screenshot \n screenshot <filename> \n screenshot <width> <height> " ) ;
2012-11-28 15:47:07 +00:00
return ;
2012-11-26 18:58:24 +00:00
}
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
// put the console away
console - > Close ( ) ;
2019-11-11 19:27:44 +00:00
2022-04-16 14:29:17 +00:00
tr . TakeScreenshot ( width , height , checkname , NULL ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
common - > Printf ( " Wrote %s \n " , checkname . c_str ( ) ) ;
}
2018-10-03 21:40:35 +00:00
2012-11-26 18:58:24 +00:00
2014-08-16 21:20:46 +00:00
/*
= = = = = = = = = = = = = = = = = =
R_EnvShot_f
envshot < basename >
Saves out env / < basename > _ft . tga , etc
2022-04-16 14:29:17 +00:00
RB : This is outdated and probably a relict from Rage . It could be updated to dump panorama images for tools like Blender or Substance Painter
2014-08-16 21:20:46 +00:00
= = = = = = = = = = = = = = = = = =
*/
2014-08-25 13:25:54 +00:00
void R_EnvShot_f ( const idCmdArgs & args )
{
2014-08-16 21:20:46 +00:00
idStr fullname ;
2014-08-25 13:25:54 +00:00
const char * baseName ;
2014-08-16 21:20:46 +00:00
int i ;
2016-06-14 08:33:50 +00:00
idMat3 axis [ 6 ] , oldAxis ;
2014-08-16 21:20:46 +00:00
renderView_t ref ;
viewDef_t primary ;
int blends ;
2014-08-25 13:25:54 +00:00
const char * extension ;
2014-08-16 21:20:46 +00:00
int size ;
2014-08-25 13:25:54 +00:00
int res_w , res_h , old_fov_x , old_fov_y ;
2019-11-11 19:27:44 +00:00
2014-08-25 13:25:54 +00:00
res_w = renderSystem - > GetWidth ( ) ;
res_h = renderSystem - > GetHeight ( ) ;
2019-11-11 19:27:44 +00:00
2014-08-25 13:25:54 +00:00
if ( args . Argc ( ) ! = 2 & & args . Argc ( ) ! = 3 & & args . Argc ( ) ! = 4 )
{
2014-08-16 21:20:46 +00:00
common - > Printf ( " USAGE: envshot <basename> [size] [blends] \n " ) ;
return ;
}
baseName = args . Argv ( 1 ) ;
2019-11-11 19:27:44 +00:00
2014-08-16 21:20:46 +00:00
blends = 1 ;
2014-08-25 13:25:54 +00:00
if ( args . Argc ( ) = = 4 )
{
2014-08-16 21:20:46 +00:00
size = atoi ( args . Argv ( 2 ) ) ;
blends = atoi ( args . Argv ( 3 ) ) ;
2014-08-25 13:25:54 +00:00
}
else if ( args . Argc ( ) = = 3 )
{
2014-08-16 21:20:46 +00:00
size = atoi ( args . Argv ( 2 ) ) ;
blends = 1 ;
2014-08-25 13:25:54 +00:00
}
else
{
2014-08-16 21:20:46 +00:00
size = 256 ;
blends = 1 ;
}
2019-11-11 19:27:44 +00:00
2014-08-25 13:25:54 +00:00
if ( ! tr . primaryView )
{
2014-08-16 21:20:46 +00:00
common - > Printf ( " No primary view. \n " ) ;
return ;
}
2019-11-11 19:27:44 +00:00
2014-08-16 21:20:46 +00:00
primary = * tr . primaryView ;
2019-11-11 19:27:44 +00:00
2014-08-16 21:20:46 +00:00
memset ( & axis , 0 , sizeof ( axis ) ) ;
2019-11-11 19:27:44 +00:00
2016-06-14 08:33:50 +00:00
// +X
axis [ 0 ] [ 0 ] [ 0 ] = 1 ;
axis [ 0 ] [ 1 ] [ 2 ] = 1 ;
2014-08-16 21:20:46 +00:00
axis [ 0 ] [ 2 ] [ 1 ] = 1 ;
2019-11-11 19:27:44 +00:00
2016-06-14 08:33:50 +00:00
// -X
2014-08-16 21:20:46 +00:00
axis [ 1 ] [ 0 ] [ 0 ] = - 1 ;
axis [ 1 ] [ 1 ] [ 2 ] = - 1 ;
axis [ 1 ] [ 2 ] [ 1 ] = 1 ;
2019-11-11 19:27:44 +00:00
2016-06-14 08:33:50 +00:00
// +Y
2014-08-16 21:20:46 +00:00
axis [ 2 ] [ 0 ] [ 1 ] = 1 ;
axis [ 2 ] [ 1 ] [ 0 ] = - 1 ;
axis [ 2 ] [ 2 ] [ 2 ] = - 1 ;
2019-11-11 19:27:44 +00:00
2016-06-14 08:33:50 +00:00
// -Y
2014-08-16 21:20:46 +00:00
axis [ 3 ] [ 0 ] [ 1 ] = - 1 ;
axis [ 3 ] [ 1 ] [ 0 ] = - 1 ;
axis [ 3 ] [ 2 ] [ 2 ] = 1 ;
2019-11-11 19:27:44 +00:00
2016-06-14 08:33:50 +00:00
// +Z
2014-08-16 21:20:46 +00:00
axis [ 4 ] [ 0 ] [ 2 ] = 1 ;
axis [ 4 ] [ 1 ] [ 0 ] = - 1 ;
axis [ 4 ] [ 2 ] [ 1 ] = 1 ;
2019-11-11 19:27:44 +00:00
2016-06-14 08:33:50 +00:00
// -Z
2014-08-16 21:20:46 +00:00
axis [ 5 ] [ 0 ] [ 2 ] = - 1 ;
axis [ 5 ] [ 1 ] [ 0 ] = 1 ;
axis [ 5 ] [ 2 ] [ 1 ] = 1 ;
2019-11-11 19:27:44 +00:00
2014-08-25 13:25:54 +00:00
// let's get the game window to a "size" resolution
if ( ( res_w ! = size ) | | ( res_h ! = size ) )
{
cvarSystem - > SetCVarInteger ( " r_windowWidth " , size ) ;
cvarSystem - > SetCVarInteger ( " r_windowHeight " , size ) ;
R_SetNewMode ( false ) ; // the same as "vid_restart"
} // FIXME that's a hack!!
2019-11-11 19:27:44 +00:00
2016-06-14 08:33:50 +00:00
// so we return to that axis and fov after the fact.
oldAxis = primary . renderView . viewaxis ;
old_fov_x = primary . renderView . fov_x ;
old_fov_y = primary . renderView . fov_y ;
2019-11-11 19:27:44 +00:00
2016-06-14 08:33:50 +00:00
for ( i = 0 ; i < 6 ; i + + )
2014-08-25 13:25:54 +00:00
{
ref = primary . renderView ;
2019-11-11 19:27:44 +00:00
2016-06-14 08:33:50 +00:00
extension = envDirection [ i ] ;
2019-11-11 19:27:44 +00:00
2014-08-16 21:20:46 +00:00
ref . fov_x = ref . fov_y = 90 ;
ref . viewaxis = axis [ i ] ;
2014-08-25 13:25:54 +00:00
fullname . Format ( " env/%s%s " , baseName , extension ) ;
2019-11-11 19:27:44 +00:00
2022-04-16 14:29:17 +00:00
tr . TakeScreenshot ( size , size , fullname , & ref ) ;
2014-08-16 21:20:46 +00:00
}
2019-11-11 19:27:44 +00:00
2014-08-25 13:25:54 +00:00
// restore the original resolution, axis and fov
ref . viewaxis = oldAxis ;
ref . fov_x = old_fov_x ;
ref . fov_y = old_fov_y ;
cvarSystem - > SetCVarInteger ( " r_windowWidth " , res_w ) ;
cvarSystem - > SetCVarInteger ( " r_windowHeight " , res_h ) ;
R_SetNewMode ( false ) ; // the same as "vid_restart"
2019-11-11 19:27:44 +00:00
2014-08-25 13:25:54 +00:00
common - > Printf ( " Wrote a env set with the name %s \n " , baseName ) ;
2014-08-16 21:20:46 +00:00
}
2012-11-26 18:58:24 +00:00
//============================================================================
2014-08-23 22:10:50 +00:00
void R_TransformCubemap ( const char * orgDirection [ 6 ] , const char * orgDir , const char * destDirection [ 6 ] , const char * destDir , const char * baseName )
2014-08-20 10:12:01 +00:00
{
2014-08-25 13:25:54 +00:00
idStr fullname ;
2014-08-20 10:12:01 +00:00
int i ;
2014-08-25 13:25:54 +00:00
bool errorInOriginalImages = false ;
2014-08-20 10:12:01 +00:00
byte * buffers [ 6 ] ;
2014-08-25 13:25:54 +00:00
int width = 0 , height = 0 ;
2019-11-11 19:27:44 +00:00
2014-08-20 10:12:01 +00:00
for ( i = 0 ; i < 6 ; i + + )
{
2014-08-25 13:25:54 +00:00
// read every image images
2022-04-16 14:29:17 +00:00
fullname . Format ( " %s/%s%s.tga " , orgDir , baseName , orgDirection [ i ] ) ;
2014-08-20 10:12:01 +00:00
common - > Printf ( " loading %s \n " , fullname . c_str ( ) ) ;
const bool captureToImage = false ;
common - > UpdateScreen ( captureToImage ) ;
2020-04-13 15:31:07 +00:00
R_LoadImage ( fullname , & buffers [ i ] , & width , & height , NULL , true , NULL ) ;
2019-11-11 19:27:44 +00:00
2014-08-25 13:25:54 +00:00
//check if the buffer is troublesome
if ( ! buffers [ i ] )
2014-08-20 10:12:01 +00:00
{
common - > Printf ( " failed. \n " ) ;
2014-08-23 22:10:50 +00:00
errorInOriginalImages = true ;
2014-08-25 13:25:54 +00:00
}
else if ( width ! = height )
{
common - > Printf ( " wrong size pal! \n \n \n get your shit together and set the size according to your images! \n \n \n inept programmers are inept! \n " ) ;
errorInOriginalImages = true ; // yeah, but don't just choke on a joke!
}
else
{
errorInOriginalImages = false ;
}
2019-11-11 19:27:44 +00:00
2014-08-25 13:25:54 +00:00
if ( errorInOriginalImages )
{
errorInOriginalImages = false ;
for ( i - - ; i > = 0 ; i - - )
{
2014-08-23 22:10:50 +00:00
Mem_Free ( buffers [ i ] ) ; // clean up every buffer from this stage down
2014-08-20 10:12:01 +00:00
}
2019-11-11 19:27:44 +00:00
2014-08-20 10:12:01 +00:00
return ;
2014-08-25 13:25:54 +00:00
}
2019-11-11 19:27:44 +00:00
2014-08-25 13:25:54 +00:00
// apply rotations and flips
R_ApplyCubeMapTransforms ( i , buffers [ i ] , width ) ;
2019-11-11 19:27:44 +00:00
2014-08-25 13:25:54 +00:00
//save the images with the appropiate skybox naming convention
2022-04-16 14:29:17 +00:00
fullname . Format ( " %s/%s/%s%s.tga " , destDir , baseName , baseName , destDirection [ i ] ) ;
2014-08-25 13:25:54 +00:00
common - > Printf ( " writing %s \n " , fullname . c_str ( ) ) ;
common - > UpdateScreen ( false ) ;
2016-06-14 08:33:50 +00:00
R_WriteTGA ( fullname , buffers [ i ] , width , width , false , " fs_basepath " ) ;
2014-08-25 13:25:54 +00:00
}
2019-11-11 19:27:44 +00:00
2014-08-20 10:12:01 +00:00
for ( i = 0 ; i < 6 ; i + + )
{
if ( buffers [ i ] )
{
Mem_Free ( buffers [ i ] ) ;
}
}
}
2014-08-23 22:10:50 +00:00
/*
= = = = = = = = = = = = = = = = = =
R_TransformEnvToSkybox_f
R_TransformEnvToSkybox_f < basename >
transforms env textures ( of the type px , py , pz , nx , ny , nz )
to skybox textures ( forward , back , left , right , up , down )
= = = = = = = = = = = = = = = = = =
*/
2014-08-25 13:25:54 +00:00
void R_TransformEnvToSkybox_f ( const idCmdArgs & args )
{
if ( args . Argc ( ) ! = 2 )
{
common - > Printf ( " USAGE: envToSky <basename> \n " ) ;
2014-08-23 22:10:50 +00:00
return ;
}
2019-11-11 19:27:44 +00:00
2014-08-25 13:25:54 +00:00
R_TransformCubemap ( envDirection , " env " , skyDirection , " skybox " , args . Argv ( 1 ) ) ;
2014-08-23 22:10:50 +00:00
}
/*
= = = = = = = = = = = = = = = = = =
R_TransformSkyboxToEnv_f
R_TransformSkyboxToEnv_f < basename >
transforms skybox textures ( forward , back , left , right , up , down )
to env textures ( of the type px , py , pz , nx , ny , nz )
= = = = = = = = = = = = = = = = = =
*/
2014-08-25 13:25:54 +00:00
void R_TransformSkyboxToEnv_f ( const idCmdArgs & args )
{
if ( args . Argc ( ) ! = 2 )
{
common - > Printf ( " USAGE: skyToEnv <basename> \n " ) ;
2014-08-23 22:10:50 +00:00
return ;
}
2019-11-11 19:27:44 +00:00
2014-08-25 13:25:54 +00:00
R_TransformCubemap ( skyDirection , " skybox " , envDirection , " env " , args . Argv ( 1 ) ) ;
2014-08-23 22:10:50 +00:00
}
2012-11-26 18:58:24 +00:00
//============================================================================
/*
= = = = = = = = = = = = = = =
R_SetColorMappings
= = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void R_SetColorMappings ( )
{
2012-11-26 18:58:24 +00:00
float b = r_brightness . GetFloat ( ) ;
float invg = 1.0f / r_gamma . GetFloat ( ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
float j = 0.0f ;
2012-11-28 15:47:07 +00:00
for ( int i = 0 ; i < 256 ; i + + , j + = b )
{
2012-11-26 18:58:24 +00:00
int inf = idMath : : Ftoi ( 0xffff * pow ( j / 255.0f , invg ) + 0.5f ) ;
tr . gammaTable [ i ] = idMath : : ClampInt ( 0 , 0xFFFF , inf ) ;
}
2021-07-30 18:08:44 +00:00
// SRS - Generalized Vulkan SDL platform
2022-12-24 19:10:55 +00:00
# if defined( VULKAN_USE_PLATFORM_SDL )
2020-03-22 11:23:52 +00:00
VKimp_SetGamma ( tr . gammaTable , tr . gammaTable , tr . gammaTable ) ;
2019-12-30 20:20:15 +00:00
# else
2012-11-26 18:58:24 +00:00
GLimp_SetGamma ( tr . gammaTable , tr . gammaTable , tr . gammaTable ) ;
2019-12-30 20:20:15 +00:00
# endif
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = =
GfxInfo_f
= = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void GfxInfo_f ( const idCmdArgs & args )
{
2012-11-26 18:58:24 +00:00
common - > Printf ( " CPU: %s \n " , Sys_GetProcessorString ( ) ) ;
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
const char * fsstrings [ ] =
2012-11-26 18:58:24 +00:00
{
" windowed " ,
" fullscreen "
} ;
2019-11-11 19:27:44 +00:00
2023-03-10 17:23:28 +00:00
common - > Printf ( " Graphics API: %s \n " , deviceManager - > GetDevice ( ) - > getGraphicsAPI ( ) = = nvrhi : : GraphicsAPI : : D3D12 ? " DirectX 12 " : " Vulkan " ) ;
common - > Printf ( " Render Device: %s \n " , deviceManager - > GetRendererString ( ) ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
// print all the display adapters, monitors, and video modes
2014-04-20 14:29:58 +00:00
//void DumpAllDisplayDevices();
//DumpAllDisplayDevices();
2019-11-11 19:27:44 +00:00
2022-03-23 19:22:05 +00:00
//common->Printf( "\nPIXELFORMAT: color(%d-bits) Z(%d-bit) stencil(%d-bits)\n", glConfig.colorBits, glConfig.depthBits, glConfig.stencilBits );
2012-11-26 18:58:24 +00:00
common - > Printf ( " MODE: %d, %d x %d %s hz: " , r_vidMode . GetInteger ( ) , renderSystem - > GetWidth ( ) , renderSystem - > GetHeight ( ) , fsstrings [ r_fullscreen . GetBool ( ) ] ) ;
2012-11-28 15:47:07 +00:00
if ( glConfig . displayFrequency )
{
2012-11-26 18:58:24 +00:00
common - > Printf ( " %d \n " , glConfig . displayFrequency ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
common - > Printf ( " N/A \n " ) ;
}
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
common - > Printf ( " ------- \n " ) ;
2019-11-11 19:27:44 +00:00
2024-11-26 20:18:42 +00:00
if ( r_swapInterval . GetInteger ( ) )
2012-11-28 15:47:07 +00:00
{
2012-11-26 18:58:24 +00:00
common - > Printf ( " Forcing swapInterval %i \n " , r_swapInterval . GetInteger ( ) ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
common - > Printf ( " swapInterval not forced \n " ) ;
}
2019-11-11 19:27:44 +00:00
2024-11-26 20:18:42 +00:00
//idLib::Printf( "%i multisamples\n", glConfig.multisamples );
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
common - > Printf ( " %5.1f cm screen width (%4.1f \" diagonal) \n " ,
2012-11-28 15:47:07 +00:00
glConfig . physicalScreenWidthInCentimeters , glConfig . physicalScreenWidthInCentimeters / 2.54f
* sqrt ( ( float ) ( 16 * 16 + 9 * 9 ) ) / 16.0f ) ;
2012-11-26 18:58:24 +00:00
extern idCVar r_forceScreenWidthCentimeters ;
2012-11-28 15:47:07 +00:00
if ( r_forceScreenWidthCentimeters . GetFloat ( ) )
{
2012-11-26 18:58:24 +00:00
common - > Printf ( " screen size manually forced to %5.1f cm width (%4.1f \" diagonal) \n " ,
2012-11-28 15:47:07 +00:00
renderSystem - > GetPhysicalScreenWidthInCentimeters ( ) , renderSystem - > GetPhysicalScreenWidthInCentimeters ( ) / 2.54f
* sqrt ( ( float ) ( 16 * 16 + 9 * 9 ) ) / 16.0f ) ;
2012-11-26 18:58:24 +00:00
}
}
/*
= = = = = = = = = = = = = = = = =
R_VidRestart_f
= = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void R_VidRestart_f ( const idCmdArgs & args )
{
2012-11-26 18:58:24 +00:00
// if OpenGL isn't started, do nothing
2018-10-05 19:43:55 +00:00
if ( ! tr . IsInitialized ( ) )
2012-11-28 15:47:07 +00:00
{
2012-11-26 18:58:24 +00:00
return ;
}
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
// set the mode without re-initializing the context
R_SetNewMode ( false ) ;
}
/*
= = = = = = = = = = = = = = = = =
R_InitMaterials
= = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void R_InitMaterials ( )
{
2012-11-26 18:58:24 +00:00
tr . defaultMaterial = declManager - > FindMaterial ( " _default " , false ) ;
2012-11-28 15:47:07 +00:00
if ( ! tr . defaultMaterial )
{
2012-11-26 18:58:24 +00:00
common - > FatalError ( " _default material not found " ) ;
}
tr . defaultPointLight = declManager - > FindMaterial ( " lights/defaultPointLight " ) ;
tr . defaultProjectedLight = declManager - > FindMaterial ( " lights/defaultProjectedLight " ) ;
2021-02-25 18:36:59 +00:00
tr . whiteMaterial = declManager - > FindMaterial ( " _white " , false ) ;
2012-11-26 18:58:24 +00:00
tr . charSetMaterial = declManager - > FindMaterial ( " textures/bigchars " ) ;
2020-05-04 15:22:51 +00:00
// RB: create implicit material
tr . imgGuiMaterial = declManager - > FindMaterial ( " _imguiFont " , true ) ;
2021-05-06 11:31:58 +00:00
ImGuiIO & io = ImGui : : GetIO ( ) ;
io . Fonts - > TexID = ( void * ) ( intptr_t ) tr . imgGuiMaterial ;
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = =
R_SizeUp_f
Keybinding command
= = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
static void R_SizeUp_f ( const idCmdArgs & args )
{
if ( r_screenFraction . GetInteger ( ) + 10 > 100 )
{
2012-11-26 18:58:24 +00:00
r_screenFraction . SetInteger ( 100 ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
r_screenFraction . SetInteger ( r_screenFraction . GetInteger ( ) + 10 ) ;
}
}
/*
= = = = = = = = = = = = = = = = =
R_SizeDown_f
Keybinding command
= = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
static void R_SizeDown_f ( const idCmdArgs & args )
{
if ( r_screenFraction . GetInteger ( ) - 10 < 10 )
{
2012-11-26 18:58:24 +00:00
r_screenFraction . SetInteger ( 10 ) ;
2012-11-28 15:47:07 +00:00
}
else
{
2012-11-26 18:58:24 +00:00
r_screenFraction . SetInteger ( r_screenFraction . GetInteger ( ) - 10 ) ;
}
}
/*
= = = = = = = = = = = = = = =
TouchGui_f
this is called from the main thread
= = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void R_TouchGui_f ( const idCmdArgs & args )
{
const char * gui = args . Argv ( 1 ) ;
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
if ( ! gui [ 0 ] )
{
2012-11-26 18:58:24 +00:00
common - > Printf ( " USAGE: touchGui <guiName> \n " ) ;
return ;
}
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
common - > Printf ( " touchGui %s \n " , gui ) ;
const bool captureToImage = false ;
common - > UpdateScreen ( captureToImage ) ;
uiManager - > Touch ( gui ) ;
}
2018-10-03 19:14:28 +00:00
2012-11-26 18:58:24 +00:00
/*
= = = = = = = = = = = = = = = = =
R_InitCommands
= = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void R_InitCommands ( )
{
2012-11-26 18:58:24 +00:00
cmdSystem - > AddCommand ( " sizeUp " , R_SizeUp_f , CMD_FL_RENDERER , " makes the rendered view larger " ) ;
cmdSystem - > AddCommand ( " sizeDown " , R_SizeDown_f , CMD_FL_RENDERER , " makes the rendered view smaller " ) ;
cmdSystem - > AddCommand ( " reloadGuis " , R_ReloadGuis_f , CMD_FL_RENDERER , " reloads guis " ) ;
cmdSystem - > AddCommand ( " listGuis " , R_ListGuis_f , CMD_FL_RENDERER , " lists guis " ) ;
cmdSystem - > AddCommand ( " touchGui " , R_TouchGui_f , CMD_FL_RENDERER , " touches a gui " ) ;
cmdSystem - > AddCommand ( " screenshot " , R_ScreenShot_f , CMD_FL_RENDERER , " takes a screenshot " ) ;
2014-08-25 13:25:54 +00:00
cmdSystem - > AddCommand ( " envshot " , R_EnvShot_f , CMD_FL_RENDERER , " takes an environment shot " ) ;
cmdSystem - > AddCommand ( " envToSky " , R_TransformEnvToSkybox_f , CMD_FL_RENDERER | CMD_FL_CHEAT , " transforms environment textures to sky box textures " ) ;
cmdSystem - > AddCommand ( " skyToEnv " , R_TransformSkyboxToEnv_f , CMD_FL_RENDERER | CMD_FL_CHEAT , " transforms sky box textures to environment textures " ) ;
2012-11-26 18:58:24 +00:00
cmdSystem - > AddCommand ( " gfxInfo " , GfxInfo_f , CMD_FL_RENDERER , " show graphics info " ) ;
cmdSystem - > AddCommand ( " modulateLights " , R_ModulateLights_f , CMD_FL_RENDERER | CMD_FL_CHEAT , " modifies shader parms on all lights " ) ;
cmdSystem - > AddCommand ( " testImage " , R_TestImage_f , CMD_FL_RENDERER | CMD_FL_CHEAT , " displays the given image centered on screen " , idCmdSystem : : ArgCompletion_ImageName ) ;
cmdSystem - > AddCommand ( " testVideo " , R_TestVideo_f , CMD_FL_RENDERER | CMD_FL_CHEAT , " displays the given cinematic " , idCmdSystem : : ArgCompletion_VideoName ) ;
cmdSystem - > AddCommand ( " reportSurfaceAreas " , R_ReportSurfaceAreas_f , CMD_FL_RENDERER , " lists all used materials sorted by surface area " ) ;
cmdSystem - > AddCommand ( " showInteractionMemory " , R_ShowInteractionMemory_f , CMD_FL_RENDERER , " shows memory used by interactions " ) ;
cmdSystem - > AddCommand ( " vid_restart " , R_VidRestart_f , CMD_FL_RENDERER , " restarts renderSystem " ) ;
cmdSystem - > AddCommand ( " listRenderEntityDefs " , R_ListRenderEntityDefs_f , CMD_FL_RENDERER , " lists the entity defs " ) ;
cmdSystem - > AddCommand ( " listRenderLightDefs " , R_ListRenderLightDefs_f , CMD_FL_RENDERER , " lists the light defs " ) ;
cmdSystem - > AddCommand ( " listModes " , R_ListModes_f , CMD_FL_RENDERER , " lists all video modes " ) ;
cmdSystem - > AddCommand ( " reloadSurface " , R_ReloadSurface_f , CMD_FL_RENDERER , " reloads the decl and images for selected surface " ) ;
}
/*
= = = = = = = = = = = = = = =
idRenderSystemLocal : : Clear
= = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idRenderSystemLocal : : Clear ( )
{
2012-11-26 18:58:24 +00:00
registered = false ;
frameCount = 0 ;
viewCount = 0 ;
frameShaderTime = 0.0f ;
ambientLightVector . Zero ( ) ;
worlds . Clear ( ) ;
primaryWorld = NULL ;
memset ( & primaryRenderView , 0 , sizeof ( primaryRenderView ) ) ;
primaryView = NULL ;
defaultMaterial = NULL ;
testImage = NULL ;
ambientCubeImage = NULL ;
viewDef = NULL ;
memset ( & pc , 0 , sizeof ( pc ) ) ;
memset ( & identitySpace , 0 , sizeof ( identitySpace ) ) ;
memset ( renderCrops , 0 , sizeof ( renderCrops ) ) ;
currentRenderCrop = 0 ;
currentColorNativeBytesOrder = 0xFFFFFFFF ;
currentGLState = 0 ;
guiRecursionLevel = 0 ;
guiModel = NULL ;
memset ( gammaTable , 0 , sizeof ( gammaTable ) ) ;
2021-04-13 13:50:46 +00:00
memset ( & cubeAxis , 0 , sizeof ( cubeAxis ) ) ; // RB
2012-11-26 18:58:24 +00:00
takingScreenshot = false ;
2021-05-01 13:59:46 +00:00
takingEnvprobe = false ;
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
if ( unitSquareTriangles ! = NULL )
{
2023-12-26 14:33:02 +00:00
Mem_Free ( unitSquareTriangles - > verts ) ;
Mem_Free ( unitSquareTriangles - > indexes ) ;
2012-11-26 18:58:24 +00:00
Mem_Free ( unitSquareTriangles ) ;
unitSquareTriangles = NULL ;
}
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
if ( zeroOneCubeTriangles ! = NULL )
{
2023-12-26 14:33:02 +00:00
Mem_Free ( zeroOneCubeTriangles - > verts ) ;
Mem_Free ( zeroOneCubeTriangles - > indexes ) ;
2012-11-26 18:58:24 +00:00
Mem_Free ( zeroOneCubeTriangles ) ;
zeroOneCubeTriangles = NULL ;
}
2019-11-11 19:27:44 +00:00
2020-05-20 16:24:45 +00:00
if ( zeroOneSphereTriangles ! = NULL )
{
2023-12-26 14:33:02 +00:00
Mem_Free ( zeroOneSphereTriangles - > verts ) ;
Mem_Free ( zeroOneSphereTriangles - > indexes ) ;
2020-05-20 16:24:45 +00:00
Mem_Free ( zeroOneSphereTriangles ) ;
zeroOneSphereTriangles = NULL ;
}
2012-11-28 15:47:07 +00:00
if ( testImageTriangles ! = NULL )
{
2023-12-26 14:33:02 +00:00
Mem_Free ( testImageTriangles - > verts ) ;
Mem_Free ( testImageTriangles - > indexes ) ;
2012-11-26 18:58:24 +00:00
Mem_Free ( testImageTriangles ) ;
testImageTriangles = NULL ;
}
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
frontEndJobList = NULL ;
2021-03-23 20:53:21 +00:00
// RB
envprobeJobList = NULL ;
2021-04-13 13:50:46 +00:00
envprobeJobs . Clear ( ) ;
lightGridJobs . Clear ( ) ;
2024-08-22 20:05:47 +00:00
2024-08-27 09:41:39 +00:00
# if defined(USE_INTRINSICS_SSE)
2024-08-22 20:05:47 +00:00
// destroy occlusion culling object and free hierarchical z-buffer
if ( maskedOcclusionCulling ! = NULL )
{
2024-08-30 16:41:03 +00:00
# if MOC_MULTITHREADED
delete maskedOcclusionThreaded ;
maskedOcclusionThreaded = NULL ;
# endif
2024-08-22 20:05:47 +00:00
MaskedOcclusionCulling : : Destroy ( maskedOcclusionCulling ) ;
2024-08-30 16:41:03 +00:00
2024-08-22 20:05:47 +00:00
maskedOcclusionCulling = NULL ;
}
2024-08-27 09:41:39 +00:00
# endif
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = =
R_MakeFullScreenTris
= = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
static srfTriangles_t * R_MakeFullScreenTris ( )
{
2012-11-26 18:58:24 +00:00
// copy verts and indexes
2012-11-28 15:47:07 +00:00
srfTriangles_t * tri = ( srfTriangles_t * ) Mem_ClearedAlloc ( sizeof ( * tri ) , TAG_RENDER_TOOLS ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
tri - > numIndexes = 6 ;
tri - > numVerts = 4 ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
int indexSize = tri - > numIndexes * sizeof ( tri - > indexes [ 0 ] ) ;
int allocatedIndexBytes = ALIGN ( indexSize , 16 ) ;
2012-11-28 15:47:07 +00:00
tri - > indexes = ( triIndex_t * ) Mem_Alloc ( allocatedIndexBytes , TAG_RENDER_TOOLS ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
int vertexSize = tri - > numVerts * sizeof ( tri - > verts [ 0 ] ) ;
int allocatedVertexBytes = ALIGN ( vertexSize , 16 ) ;
2012-11-28 15:47:07 +00:00
tri - > verts = ( idDrawVert * ) Mem_ClearedAlloc ( allocatedVertexBytes , TAG_RENDER_TOOLS ) ;
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
idDrawVert * verts = tri - > verts ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
triIndex_t tempIndexes [ 6 ] = { 3 , 0 , 2 , 2 , 0 , 1 } ;
memcpy ( tri - > indexes , tempIndexes , indexSize ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
verts [ 0 ] . xyz [ 0 ] = - 1.0f ;
verts [ 0 ] . xyz [ 1 ] = 1.0f ;
verts [ 0 ] . SetTexCoord ( 0.0f , 1.0f ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
verts [ 1 ] . xyz [ 0 ] = 1.0f ;
verts [ 1 ] . xyz [ 1 ] = 1.0f ;
verts [ 1 ] . SetTexCoord ( 1.0f , 1.0f ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
verts [ 2 ] . xyz [ 0 ] = 1.0f ;
verts [ 2 ] . xyz [ 1 ] = - 1.0f ;
verts [ 2 ] . SetTexCoord ( 1.0f , 0.0f ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
verts [ 3 ] . xyz [ 0 ] = - 1.0f ;
verts [ 3 ] . xyz [ 1 ] = - 1.0f ;
verts [ 3 ] . SetTexCoord ( 0.0f , 0.0f ) ;
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
for ( int i = 0 ; i < 4 ; i + + )
{
2012-11-26 18:58:24 +00:00
verts [ i ] . SetColor ( 0xffffffff ) ;
}
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
return tri ;
}
/*
= = = = = = = = = = = = =
R_MakeZeroOneCubeTris
= = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
static srfTriangles_t * R_MakeZeroOneCubeTris ( )
{
srfTriangles_t * tri = ( srfTriangles_t * ) Mem_ClearedAlloc ( sizeof ( * tri ) , TAG_RENDER_TOOLS ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
tri - > numVerts = 8 ;
tri - > numIndexes = 36 ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
const int indexSize = tri - > numIndexes * sizeof ( tri - > indexes [ 0 ] ) ;
const int allocatedIndexBytes = ALIGN ( indexSize , 16 ) ;
2012-11-28 15:47:07 +00:00
tri - > indexes = ( triIndex_t * ) Mem_Alloc ( allocatedIndexBytes , TAG_RENDER_TOOLS ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
const int vertexSize = tri - > numVerts * sizeof ( tri - > verts [ 0 ] ) ;
const int allocatedVertexBytes = ALIGN ( vertexSize , 16 ) ;
2012-11-28 15:47:07 +00:00
tri - > verts = ( idDrawVert * ) Mem_ClearedAlloc ( allocatedVertexBytes , TAG_RENDER_TOOLS ) ;
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
idDrawVert * verts = tri - > verts ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
const float low = 0.0f ;
const float high = 1.0f ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
idVec3 center ( 0.0f ) ;
2012-11-28 15:47:07 +00:00
idVec3 mx ( low , 0.0f , 0.0f ) ;
2012-11-26 18:58:24 +00:00
idVec3 px ( high , 0.0f , 0.0f ) ;
idVec3 my ( 0.0f , low , 0.0f ) ;
idVec3 py ( 0.0f , high , 0.0f ) ;
idVec3 mz ( 0.0f , 0.0f , low ) ;
idVec3 pz ( 0.0f , 0.0f , high ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
verts [ 0 ] . xyz = center + mx + my + mz ;
verts [ 1 ] . xyz = center + px + my + mz ;
verts [ 2 ] . xyz = center + px + py + mz ;
verts [ 3 ] . xyz = center + mx + py + mz ;
verts [ 4 ] . xyz = center + mx + my + pz ;
verts [ 5 ] . xyz = center + px + my + pz ;
verts [ 6 ] . xyz = center + px + py + pz ;
verts [ 7 ] . xyz = center + mx + py + pz ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
// bottom
2012-11-28 15:47:07 +00:00
tri - > indexes [ 0 * 3 + 0 ] = 2 ;
tri - > indexes [ 0 * 3 + 1 ] = 3 ;
tri - > indexes [ 0 * 3 + 2 ] = 0 ;
tri - > indexes [ 1 * 3 + 0 ] = 1 ;
tri - > indexes [ 1 * 3 + 1 ] = 2 ;
tri - > indexes [ 1 * 3 + 2 ] = 0 ;
2012-11-26 18:58:24 +00:00
// back
2012-11-28 15:47:07 +00:00
tri - > indexes [ 2 * 3 + 0 ] = 5 ;
tri - > indexes [ 2 * 3 + 1 ] = 1 ;
tri - > indexes [ 2 * 3 + 2 ] = 0 ;
tri - > indexes [ 3 * 3 + 0 ] = 4 ;
tri - > indexes [ 3 * 3 + 1 ] = 5 ;
tri - > indexes [ 3 * 3 + 2 ] = 0 ;
2012-11-26 18:58:24 +00:00
// left
2012-11-28 15:47:07 +00:00
tri - > indexes [ 4 * 3 + 0 ] = 7 ;
tri - > indexes [ 4 * 3 + 1 ] = 4 ;
tri - > indexes [ 4 * 3 + 2 ] = 0 ;
tri - > indexes [ 5 * 3 + 0 ] = 3 ;
tri - > indexes [ 5 * 3 + 1 ] = 7 ;
tri - > indexes [ 5 * 3 + 2 ] = 0 ;
2012-11-26 18:58:24 +00:00
// right
2012-11-28 15:47:07 +00:00
tri - > indexes [ 6 * 3 + 0 ] = 1 ;
tri - > indexes [ 6 * 3 + 1 ] = 5 ;
tri - > indexes [ 6 * 3 + 2 ] = 6 ;
tri - > indexes [ 7 * 3 + 0 ] = 2 ;
tri - > indexes [ 7 * 3 + 1 ] = 1 ;
tri - > indexes [ 7 * 3 + 2 ] = 6 ;
2012-11-26 18:58:24 +00:00
// front
2012-11-28 15:47:07 +00:00
tri - > indexes [ 8 * 3 + 0 ] = 3 ;
tri - > indexes [ 8 * 3 + 1 ] = 2 ;
tri - > indexes [ 8 * 3 + 2 ] = 6 ;
tri - > indexes [ 9 * 3 + 0 ] = 7 ;
tri - > indexes [ 9 * 3 + 1 ] = 3 ;
tri - > indexes [ 9 * 3 + 2 ] = 6 ;
2012-11-26 18:58:24 +00:00
// top
2012-11-28 15:47:07 +00:00
tri - > indexes [ 10 * 3 + 0 ] = 4 ;
tri - > indexes [ 10 * 3 + 1 ] = 7 ;
tri - > indexes [ 10 * 3 + 2 ] = 6 ;
tri - > indexes [ 11 * 3 + 0 ] = 5 ;
tri - > indexes [ 11 * 3 + 1 ] = 4 ;
tri - > indexes [ 11 * 3 + 2 ] = 6 ;
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
for ( int i = 0 ; i < 4 ; i + + )
{
2012-11-26 18:58:24 +00:00
verts [ i ] . SetColor ( 0xffffffff ) ;
}
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
return tri ;
}
2020-05-20 16:24:45 +00:00
// RB begin
2024-08-27 09:41:39 +00:00
# if defined(USE_INTRINSICS_SSE)
2024-08-21 22:05:04 +00:00
static void R_MakeZeroOneCubeTrisForMaskedOcclusionCulling ( )
{
2024-08-26 08:26:40 +00:00
const float low = 0.0f ;
2024-08-21 22:05:04 +00:00
const float high = 1.0f ;
idVec3 center ( 0.0f ) ;
idVec3 mx ( low , 0.0f , 0.0f ) ;
idVec3 px ( high , 0.0f , 0.0f ) ;
idVec3 my ( 0.0f , low , 0.0f ) ;
idVec3 py ( 0.0f , high , 0.0f ) ;
idVec3 mz ( 0.0f , 0.0f , low ) ;
idVec3 pz ( 0.0f , 0.0f , high ) ;
2024-08-22 20:05:47 +00:00
idVec4 * verts = tr . maskedZeroOneCubeVerts ;
2024-08-21 22:05:04 +00:00
verts [ 0 ] . ToVec3 ( ) = center + mx + my + mz ;
verts [ 1 ] . ToVec3 ( ) = center + px + my + mz ;
verts [ 2 ] . ToVec3 ( ) = center + px + py + mz ;
verts [ 3 ] . ToVec3 ( ) = center + mx + py + mz ;
verts [ 4 ] . ToVec3 ( ) = center + mx + my + pz ;
verts [ 5 ] . ToVec3 ( ) = center + px + my + pz ;
verts [ 6 ] . ToVec3 ( ) = center + px + py + pz ;
verts [ 7 ] . ToVec3 ( ) = center + mx + py + pz ;
verts [ 0 ] . w = 1 ;
verts [ 1 ] . w = 1 ;
verts [ 2 ] . w = 1 ;
verts [ 3 ] . w = 1 ;
verts [ 4 ] . w = 1 ;
verts [ 5 ] . w = 1 ;
verts [ 6 ] . w = 1 ;
verts [ 7 ] . w = 1 ;
2024-08-22 20:05:47 +00:00
unsigned int * indexes = tr . maskedZeroOneCubeIndexes ;
2024-08-21 22:05:04 +00:00
// bottom
indexes [ 0 * 3 + 0 ] = 2 ;
indexes [ 0 * 3 + 1 ] = 3 ;
indexes [ 0 * 3 + 2 ] = 0 ;
indexes [ 1 * 3 + 0 ] = 1 ;
indexes [ 1 * 3 + 1 ] = 2 ;
indexes [ 1 * 3 + 2 ] = 0 ;
// back
indexes [ 2 * 3 + 0 ] = 5 ;
indexes [ 2 * 3 + 1 ] = 1 ;
indexes [ 2 * 3 + 2 ] = 0 ;
indexes [ 3 * 3 + 0 ] = 4 ;
indexes [ 3 * 3 + 1 ] = 5 ;
indexes [ 3 * 3 + 2 ] = 0 ;
// left
indexes [ 4 * 3 + 0 ] = 7 ;
indexes [ 4 * 3 + 1 ] = 4 ;
indexes [ 4 * 3 + 2 ] = 0 ;
indexes [ 5 * 3 + 0 ] = 3 ;
indexes [ 5 * 3 + 1 ] = 7 ;
indexes [ 5 * 3 + 2 ] = 0 ;
// right
indexes [ 6 * 3 + 0 ] = 1 ;
indexes [ 6 * 3 + 1 ] = 5 ;
indexes [ 6 * 3 + 2 ] = 6 ;
indexes [ 7 * 3 + 0 ] = 2 ;
indexes [ 7 * 3 + 1 ] = 1 ;
indexes [ 7 * 3 + 2 ] = 6 ;
// front
indexes [ 8 * 3 + 0 ] = 3 ;
indexes [ 8 * 3 + 1 ] = 2 ;
indexes [ 8 * 3 + 2 ] = 6 ;
indexes [ 9 * 3 + 0 ] = 7 ;
indexes [ 9 * 3 + 1 ] = 3 ;
indexes [ 9 * 3 + 2 ] = 6 ;
// top
indexes [ 10 * 3 + 0 ] = 4 ;
indexes [ 10 * 3 + 1 ] = 7 ;
indexes [ 10 * 3 + 2 ] = 6 ;
indexes [ 11 * 3 + 0 ] = 5 ;
indexes [ 11 * 3 + 1 ] = 4 ;
indexes [ 11 * 3 + 2 ] = 6 ;
}
2024-08-26 20:36:58 +00:00
static void R_MakeUnitCubeTrisForMaskedOcclusionCulling ( )
{
const float low = - 1.0f ;
const float high = 1.0f ;
idVec3 center ( 0.0f ) ;
idVec3 mx ( low , 0.0f , 0.0f ) ;
idVec3 px ( high , 0.0f , 0.0f ) ;
idVec3 my ( 0.0f , low , 0.0f ) ;
idVec3 py ( 0.0f , high , 0.0f ) ;
idVec3 mz ( 0.0f , 0.0f , low ) ;
idVec3 pz ( 0.0f , 0.0f , high ) ;
idVec4 * verts = tr . maskedUnitCubeVerts ;
verts [ 0 ] . ToVec3 ( ) = center + mx + my + mz ;
verts [ 1 ] . ToVec3 ( ) = center + px + my + mz ;
verts [ 2 ] . ToVec3 ( ) = center + px + py + mz ;
verts [ 3 ] . ToVec3 ( ) = center + mx + py + mz ;
verts [ 4 ] . ToVec3 ( ) = center + mx + my + pz ;
verts [ 5 ] . ToVec3 ( ) = center + px + my + pz ;
verts [ 6 ] . ToVec3 ( ) = center + px + py + pz ;
verts [ 7 ] . ToVec3 ( ) = center + mx + py + pz ;
verts [ 0 ] . w = 1 ;
verts [ 1 ] . w = 1 ;
verts [ 2 ] . w = 1 ;
verts [ 3 ] . w = 1 ;
verts [ 4 ] . w = 1 ;
verts [ 5 ] . w = 1 ;
verts [ 6 ] . w = 1 ;
verts [ 7 ] . w = 1 ;
}
2024-08-27 09:41:39 +00:00
# endif
2024-08-26 20:36:58 +00:00
2020-05-20 16:24:45 +00:00
static srfTriangles_t * R_MakeZeroOneSphereTris ( )
{
srfTriangles_t * tri = ( srfTriangles_t * ) Mem_ClearedAlloc ( sizeof ( * tri ) , TAG_RENDER_TOOLS ) ;
const float radius = 1.0f ;
const int rings = 20.0f ;
const int sectors = 20.0f ;
tri - > numVerts = ( rings * sectors ) ;
tri - > numIndexes = ( ( rings - 1 ) * sectors ) * 6 ;
const int indexSize = tri - > numIndexes * sizeof ( tri - > indexes [ 0 ] ) ;
const int allocatedIndexBytes = ALIGN ( indexSize , 16 ) ;
tri - > indexes = ( triIndex_t * ) Mem_Alloc ( allocatedIndexBytes , TAG_RENDER_TOOLS ) ;
const int vertexSize = tri - > numVerts * sizeof ( tri - > verts [ 0 ] ) ;
const int allocatedVertexBytes = ALIGN ( vertexSize , 16 ) ;
tri - > verts = ( idDrawVert * ) Mem_ClearedAlloc ( allocatedVertexBytes , TAG_RENDER_TOOLS ) ;
idDrawVert * verts = tri - > verts ;
float const R = 1.0f / ( float ) ( rings - 1 ) ;
float const S = 1.0f / ( float ) ( sectors - 1 ) ;
int numTris = 0 ;
int numVerts = 0 ;
for ( int r = 0 ; r < rings ; + + r )
{
for ( int s = 0 ; s < sectors ; + + s )
{
const float y = sin ( - idMath : : HALF_PI + idMath : : PI * r * R ) ;
const float x = cos ( 2 * idMath : : PI * s * S ) * sin ( idMath : : PI * r * R ) ;
const float z = sin ( 2 * idMath : : PI * s * S ) * sin ( idMath : : PI * r * R ) ;
verts [ numVerts ] . SetTexCoord ( s * S , r * R ) ;
verts [ numVerts ] . xyz = idVec3 ( x , y , z ) * radius ;
2021-04-15 11:11:27 +00:00
verts [ numVerts ] . SetNormal ( x , y , z ) ;
2020-05-20 16:24:45 +00:00
verts [ numVerts ] . SetColor ( 0xffffffff ) ;
numVerts + + ;
if ( r < ( rings - 1 ) )
{
int curRow = r * sectors ;
int nextRow = ( r + 1 ) * sectors ;
int nextS = ( s + 1 ) % sectors ;
tri - > indexes [ ( numTris * 3 ) + 2 ] = ( curRow + s ) ;
tri - > indexes [ ( numTris * 3 ) + 1 ] = ( nextRow + s ) ;
tri - > indexes [ ( numTris * 3 ) + 0 ] = ( nextRow + nextS ) ;
numTris + = 1 ;
tri - > indexes [ ( numTris * 3 ) + 2 ] = ( curRow + s ) ;
tri - > indexes [ ( numTris * 3 ) + 1 ] = ( nextRow + nextS ) ;
tri - > indexes [ ( numTris * 3 ) + 0 ] = ( curRow + nextS ) ;
numTris + = 1 ;
}
}
}
return tri ;
}
// RB end
2012-11-26 18:58:24 +00:00
/*
= = = = = = = = = = = = = = = =
R_MakeTestImageTriangles
Initializes the Test Image Triangles
= = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
srfTriangles_t * R_MakeTestImageTriangles ( )
{
srfTriangles_t * tri = ( srfTriangles_t * ) Mem_ClearedAlloc ( sizeof ( * tri ) , TAG_RENDER_TOOLS ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
tri - > numIndexes = 6 ;
tri - > numVerts = 4 ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
int indexSize = tri - > numIndexes * sizeof ( tri - > indexes [ 0 ] ) ;
int allocatedIndexBytes = ALIGN ( indexSize , 16 ) ;
2012-11-28 15:47:07 +00:00
tri - > indexes = ( triIndex_t * ) Mem_Alloc ( allocatedIndexBytes , TAG_RENDER_TOOLS ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
int vertexSize = tri - > numVerts * sizeof ( tri - > verts [ 0 ] ) ;
int allocatedVertexBytes = ALIGN ( vertexSize , 16 ) ;
2012-11-28 15:47:07 +00:00
tri - > verts = ( idDrawVert * ) Mem_ClearedAlloc ( allocatedVertexBytes , TAG_RENDER_TOOLS ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
ALIGNTYPE16 triIndex_t tempIndexes [ 6 ] = { 3 , 0 , 2 , 2 , 0 , 1 } ;
memcpy ( tri - > indexes , tempIndexes , indexSize ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
idDrawVert * tempVerts = tri - > verts ;
tempVerts [ 0 ] . xyz [ 0 ] = 0.0f ;
tempVerts [ 0 ] . xyz [ 1 ] = 0.0f ;
tempVerts [ 0 ] . xyz [ 2 ] = 0 ;
tempVerts [ 0 ] . SetTexCoord ( 0.0 , 0.0f ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
tempVerts [ 1 ] . xyz [ 0 ] = 1.0f ;
tempVerts [ 1 ] . xyz [ 1 ] = 0.0f ;
tempVerts [ 1 ] . xyz [ 2 ] = 0 ;
tempVerts [ 1 ] . SetTexCoord ( 1.0f , 0.0f ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
tempVerts [ 2 ] . xyz [ 0 ] = 1.0f ;
tempVerts [ 2 ] . xyz [ 1 ] = 1.0f ;
tempVerts [ 2 ] . xyz [ 2 ] = 0 ;
tempVerts [ 2 ] . SetTexCoord ( 1.0f , 1.0f ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
tempVerts [ 3 ] . xyz [ 0 ] = 0.0f ;
tempVerts [ 3 ] . xyz [ 1 ] = 1.0f ;
tempVerts [ 3 ] . xyz [ 2 ] = 0 ;
tempVerts [ 3 ] . SetTexCoord ( 0.0f , 1.0f ) ;
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
for ( int i = 0 ; i < 4 ; i + + )
{
2012-11-26 18:58:24 +00:00
tempVerts [ i ] . SetColor ( 0xFFFFFFFF ) ;
}
return tri ;
}
/*
= = = = = = = = = = = = = = =
idRenderSystemLocal : : Init
= = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idRenderSystemLocal : : Init ( )
{
2012-11-26 18:58:24 +00:00
common - > Printf ( " ------- Initializing renderSystem -------- \n " ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
// clear all our internal state
viewCount = 1 ; // so cleared structures never match viewCount
// we used to memset tr, but now that it is a class, we can't, so
// there may be other state we need to reset
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
ambientLightVector [ 0 ] = 0.5f ;
ambientLightVector [ 1 ] = 0.5f - 0.385f ;
ambientLightVector [ 2 ] = 0.8925f ;
ambientLightVector [ 3 ] = 1.0f ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
R_InitCommands ( ) ;
2019-11-11 19:27:44 +00:00
2018-10-05 19:43:55 +00:00
// allocate the frame data, which may be more if smp is enabled
R_InitFrameData ( ) ;
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
guiModel = new ( TAG_RENDER ) idGuiModel ;
2012-11-26 18:58:24 +00:00
guiModel - > Clear ( ) ;
tr_guiModel = guiModel ; // for DeviceContext fast path
2019-11-11 19:27:44 +00:00
2015-12-20 11:28:46 +00:00
globalImages - > Init ( ) ;
2019-11-11 19:27:44 +00:00
2014-05-10 12:40:01 +00:00
// RB begin
Framebuffer : : Init ( ) ;
// RB end
2019-11-11 19:27:44 +00:00
2015-12-20 11:28:46 +00:00
idCinematic : : InitCinematic ( ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
// build brightness translation tables
R_SetColorMappings ( ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
R_InitMaterials ( ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
renderModelManager - > Init ( ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
// set the identity space
2012-11-28 15:47:07 +00:00
identitySpace . modelMatrix [ 0 * 4 + 0 ] = 1.0f ;
identitySpace . modelMatrix [ 1 * 4 + 1 ] = 1.0f ;
identitySpace . modelMatrix [ 2 * 4 + 2 ] = 1.0f ;
2019-11-11 19:27:44 +00:00
2021-04-13 13:50:46 +00:00
// set cubemap axis for cubemap sampling tools
// +X
cubeAxis [ 0 ] [ 0 ] [ 0 ] = 1 ;
cubeAxis [ 0 ] [ 1 ] [ 2 ] = 1 ;
cubeAxis [ 0 ] [ 2 ] [ 1 ] = 1 ;
// -X
cubeAxis [ 1 ] [ 0 ] [ 0 ] = - 1 ;
cubeAxis [ 1 ] [ 1 ] [ 2 ] = - 1 ;
cubeAxis [ 1 ] [ 2 ] [ 1 ] = 1 ;
// +Y
cubeAxis [ 2 ] [ 0 ] [ 1 ] = 1 ;
cubeAxis [ 2 ] [ 1 ] [ 0 ] = - 1 ;
cubeAxis [ 2 ] [ 2 ] [ 2 ] = - 1 ;
// -Y
cubeAxis [ 3 ] [ 0 ] [ 1 ] = - 1 ;
cubeAxis [ 3 ] [ 1 ] [ 0 ] = - 1 ;
cubeAxis [ 3 ] [ 2 ] [ 2 ] = 1 ;
// +Z
cubeAxis [ 4 ] [ 0 ] [ 2 ] = 1 ;
cubeAxis [ 4 ] [ 1 ] [ 0 ] = - 1 ;
cubeAxis [ 4 ] [ 2 ] [ 1 ] = 1 ;
// -Z
cubeAxis [ 5 ] [ 0 ] [ 2 ] = - 1 ;
cubeAxis [ 5 ] [ 1 ] [ 0 ] = 1 ;
cubeAxis [ 5 ] [ 2 ] [ 1 ] = 1 ;
2012-11-26 18:58:24 +00:00
// make sure the tr.unitSquareTriangles data is current in the vertex / index cache
2012-11-28 15:47:07 +00:00
if ( unitSquareTriangles = = NULL )
{
2012-11-26 18:58:24 +00:00
unitSquareTriangles = R_MakeFullScreenTris ( ) ;
}
2020-05-20 16:24:45 +00:00
2012-11-26 18:58:24 +00:00
// make sure the tr.zeroOneCubeTriangles data is current in the vertex / index cache
2012-11-28 15:47:07 +00:00
if ( zeroOneCubeTriangles = = NULL )
{
2012-11-26 18:58:24 +00:00
zeroOneCubeTriangles = R_MakeZeroOneCubeTris ( ) ;
2020-05-17 11:29:18 +00:00
R_DeriveTangents ( zeroOneCubeTriangles ) ; // RB: we need normals for debugging reflections
2012-11-26 18:58:24 +00:00
}
2020-05-20 16:24:45 +00:00
// RB make sure the tr.zeroOneSphereTriangles data is current in the vertex / index cache
if ( zeroOneSphereTriangles = = NULL )
{
zeroOneSphereTriangles = R_MakeZeroOneSphereTris ( ) ;
//R_DeriveTangents( zeroOneSphereTriangles );
}
2012-11-26 18:58:24 +00:00
// make sure the tr.testImageTriangles data is current in the vertex / index cache
2012-11-28 15:47:07 +00:00
if ( testImageTriangles = = NULL )
{
2012-11-26 18:58:24 +00:00
testImageTriangles = R_MakeTestImageTriangles ( ) ;
}
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
frontEndJobList = parallelJobManager - > AllocJobList ( JOBLIST_RENDERER_FRONTEND , JOBLIST_PRIORITY_MEDIUM , 2048 , 0 , NULL ) ;
2021-03-23 20:53:21 +00:00
envprobeJobList = parallelJobManager - > AllocJobList ( JOBLIST_UTILITY , JOBLIST_PRIORITY_MEDIUM , 2048 , 0 , NULL ) ; // RB
2019-11-11 19:27:44 +00:00
2022-09-22 16:34:07 +00:00
if ( deviceManager - > GetGraphicsAPI ( ) = = nvrhi : : GraphicsAPI : : VULKAN )
{
// avoid GL_BlockingSwapBuffers
omitSwapBuffers = true ;
}
2019-11-11 19:27:44 +00:00
2024-08-27 09:41:39 +00:00
# if defined(USE_INTRINSICS_SSE)
2024-08-21 22:05:04 +00:00
// Flush denorms to zero to avoid performance issues with small values
_mm_setcsr ( _mm_getcsr ( ) | 0x8040 ) ;
maskedOcclusionCulling = MaskedOcclusionCulling : : Create ( ) ;
2024-08-30 16:41:03 +00:00
# if MOC_MULTITHREADED
maskedOcclusionThreaded = new CullingThreadpool ( 2 , 10 , 6 , 128 ) ;
maskedOcclusionThreaded - > SetBuffer ( maskedOcclusionCulling ) ;
2024-09-02 21:14:08 +00:00
maskedOcclusionThreaded - > WakeThreads ( ) ;
2024-08-30 16:41:03 +00:00
# endif
2024-08-21 22:05:04 +00:00
R_MakeZeroOneCubeTrisForMaskedOcclusionCulling ( ) ;
2024-08-26 08:26:40 +00:00
R_MakeUnitCubeTrisForMaskedOcclusionCulling ( ) ;
2024-08-27 09:41:39 +00:00
# endif
2024-08-21 22:05:04 +00:00
2012-11-26 18:58:24 +00:00
// make sure the command buffers are ready to accept the first screen update
2020-03-29 15:12:11 +00:00
SwapCommandBuffers ( NULL , NULL , NULL , NULL , NULL , NULL ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
common - > Printf ( " renderSystem initialized. \n " ) ;
common - > Printf ( " -------------------------------------- \n " ) ;
}
/*
= = = = = = = = = = = = = = =
idRenderSystemLocal : : Shutdown
= = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idRenderSystemLocal : : Shutdown ( )
{
2012-11-26 18:58:24 +00:00
common - > Printf ( " idRenderSystem::Shutdown() \n " ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
fonts . DeleteContents ( ) ;
2019-11-11 19:27:44 +00:00
2018-10-05 19:43:55 +00:00
if ( IsInitialized ( ) )
2012-11-28 15:47:07 +00:00
{
2012-11-26 18:58:24 +00:00
globalImages - > PurgeAllImages ( ) ;
}
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
renderModelManager - > Shutdown ( ) ;
2019-11-11 19:27:44 +00:00
2022-03-16 00:26:47 +00:00
// SRS - if testVideo is currently playing, make sure cinematic is deleted before ShutdownCinematic()
if ( tr . testVideo )
{
delete tr . testVideo ;
tr . testVideo = NULL ;
}
2014-05-18 13:17:15 +00:00
idCinematic : : ShutdownCinematic ( ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
globalImages - > Shutdown ( ) ;
2019-11-11 19:27:44 +00:00
2014-05-10 12:40:01 +00:00
// RB begin
Framebuffer : : Shutdown ( ) ;
// RB end
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
// free frame memory
R_ShutdownFrameData ( ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
UnbindBufferObjects ( ) ;
2021-04-29 13:20:45 +00:00
2024-02-05 19:24:15 +00:00
// SRS - wait for device idle before freeing any resources the GPU may be using, otherwise get errors on shutdown
deviceManager - > GetDevice ( ) - > waitForIdle ( ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
// free the vertex cache, which should have nothing allocated now
vertexCache . Shutdown ( ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
RB_ShutdownDebugTools ( ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
delete guiModel ;
2019-11-11 19:27:44 +00:00
2022-02-21 16:59:13 +00:00
parallelJobManager - > FreeJobList ( envprobeJobList ) ;
2012-11-26 18:58:24 +00:00
parallelJobManager - > FreeJobList ( frontEndJobList ) ;
2019-11-11 19:27:44 +00:00
2012-11-26 18:58:24 +00:00
Clear ( ) ;
2019-11-11 19:27:44 +00:00
2022-10-28 18:11:10 +00:00
commandList . Reset ( ) ;
2012-11-26 18:58:24 +00:00
ShutdownOpenGL ( ) ;
2019-11-11 19:27:44 +00:00
2018-10-05 19:43:55 +00:00
bInitialized = false ;
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idRenderSystemLocal : : ResetGuiModels
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idRenderSystemLocal : : ResetGuiModels ( )
{
2012-11-26 18:58:24 +00:00
delete guiModel ;
2012-11-28 15:47:07 +00:00
guiModel = new ( TAG_RENDER ) idGuiModel ;
2012-11-26 18:58:24 +00:00
guiModel - > Clear ( ) ;
2022-07-03 09:26:54 +00:00
guiModel - > BeginFrame ( ) ;
2012-11-26 18:58:24 +00:00
tr_guiModel = guiModel ; // for DeviceContext fast path
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idRenderSystemLocal : : BeginLevelLoad
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idRenderSystemLocal : : BeginLevelLoad ( )
{
2022-06-03 16:47:02 +00:00
// clear binding sets for previous level images and light data #676
backend . ClearCaches ( ) ;
2012-11-26 18:58:24 +00:00
globalImages - > BeginLevelLoad ( ) ;
renderModelManager - > BeginLevelLoad ( ) ;
2019-11-11 19:27:44 +00:00
2012-11-28 15:47:07 +00:00
// Re-Initialize the Default Materials if needed.
2012-11-26 18:58:24 +00:00
R_InitMaterials ( ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idRenderSystemLocal : : LoadLevelImages
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idRenderSystemLocal : : LoadLevelImages ( )
{
2012-11-26 18:58:24 +00:00
globalImages - > LoadLevelImages ( false ) ;
2022-02-21 20:26:36 +00:00
2022-02-21 16:59:13 +00:00
deviceManager - > GetDevice ( ) - > waitForIdle ( ) ;
deviceManager - > GetDevice ( ) - > runGarbageCollection ( ) ;
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idRenderSystemLocal : : Preload
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idRenderSystemLocal : : Preload ( const idPreloadManifest & manifest , const char * mapName )
{
2012-11-26 18:58:24 +00:00
globalImages - > Preload ( manifest , true ) ;
uiManager - > Preload ( mapName ) ;
renderModelManager - > Preload ( manifest ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idRenderSystemLocal : : EndLevelLoad
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idRenderSystemLocal : : EndLevelLoad ( )
{
2012-11-26 18:58:24 +00:00
renderModelManager - > EndLevelLoad ( ) ;
globalImages - > EndLevelLoad ( ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idRenderSystemLocal : : BeginAutomaticBackgroundSwaps
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idRenderSystemLocal : : BeginAutomaticBackgroundSwaps ( autoRenderIconType_t icon )
{
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idRenderSystemLocal : : EndAutomaticBackgroundSwaps
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idRenderSystemLocal : : EndAutomaticBackgroundSwaps ( )
{
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idRenderSystemLocal : : AreAutomaticBackgroundSwapsRunning
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
bool idRenderSystemLocal : : AreAutomaticBackgroundSwapsRunning ( autoRenderIconType_t * icon ) const
{
2012-11-26 18:58:24 +00:00
return false ;
}
/*
= = = = = = = = = = = =
idRenderSystemLocal : : RegisterFont
= = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
idFont * idRenderSystemLocal : : RegisterFont ( const char * fontName )
{
2012-11-26 18:58:24 +00:00
idStrStatic < MAX_OSPATH > baseFontName = fontName ;
baseFontName . Replace ( " fonts/ " , " " ) ;
2012-11-28 15:47:07 +00:00
for ( int i = 0 ; i < fonts . Num ( ) ; i + + )
{
if ( idStr : : Icmp ( fonts [ i ] - > GetName ( ) , baseFontName ) = = 0 )
{
2012-11-26 18:58:24 +00:00
fonts [ i ] - > Touch ( ) ;
return fonts [ i ] ;
}
}
2012-11-28 15:47:07 +00:00
idFont * newFont = new ( TAG_FONT ) idFont ( baseFontName ) ;
2012-11-26 18:58:24 +00:00
fonts . Append ( newFont ) ;
return newFont ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idRenderSystemLocal : : ResetFonts
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idRenderSystemLocal : : ResetFonts ( )
{
2012-11-26 18:58:24 +00:00
fonts . DeleteContents ( true ) ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idRenderSystemLocal : : InitOpenGL
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2022-02-21 16:59:13 +00:00
void idRenderSystemLocal : : InitBackend ( )
2012-11-28 15:47:07 +00:00
{
2012-11-26 18:58:24 +00:00
// if OpenGL isn't started, start it now
2018-10-05 19:43:55 +00:00
if ( ! IsInitialized ( ) )
2012-11-28 15:47:07 +00:00
{
2018-10-03 20:05:30 +00:00
backend . Init ( ) ;
2019-11-11 19:27:44 +00:00
2022-02-21 16:59:13 +00:00
if ( ! commandList )
{
commandList = deviceManager - > GetDevice ( ) - > createCommandList ( ) ;
}
commandList - > open ( ) ;
2022-02-21 20:26:36 +00:00
2023-03-10 17:49:32 +00:00
// Reloading images here causes the rendertargets to get deleted
2022-02-21 16:59:13 +00:00
globalImages - > ReloadImages ( true , commandList ) ;
2022-02-21 20:26:36 +00:00
2022-02-21 16:59:13 +00:00
commandList - > close ( ) ;
deviceManager - > GetDevice ( ) - > executeCommandList ( commandList ) ;
2012-11-26 18:58:24 +00:00
}
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idRenderSystemLocal : : ShutdownOpenGL
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
void idRenderSystemLocal : : ShutdownOpenGL ( )
{
2012-11-26 18:58:24 +00:00
// free the context and close the window
R_ShutdownFrameData ( ) ;
2019-11-11 19:27:44 +00:00
2018-10-03 20:05:30 +00:00
backend . Shutdown ( ) ;
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idRenderSystemLocal : : IsOpenGLRunning
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
bool idRenderSystemLocal : : IsOpenGLRunning ( ) const
{
2018-10-05 19:43:55 +00:00
return IsInitialized ( ) ;
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idRenderSystemLocal : : IsFullScreen
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
bool idRenderSystemLocal : : IsFullScreen ( ) const
{
2012-11-26 18:58:24 +00:00
return glConfig . isFullscreen ! = 0 ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idRenderSystemLocal : : GetWidth
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
int idRenderSystemLocal : : GetWidth ( ) const
{
2024-11-26 20:18:42 +00:00
// do something similar in case the VR API requires it
/*
2012-11-28 15:47:07 +00:00
if ( glConfig . stereo3Dmode = = STEREO3D_SIDE_BY_SIDE | | glConfig . stereo3Dmode = = STEREO3D_SIDE_BY_SIDE_COMPRESSED )
{
2012-11-26 18:58:24 +00:00
return glConfig . nativeScreenWidth > > 1 ;
}
2024-11-26 20:18:42 +00:00
*/
2024-10-23 13:41:42 +00:00
2012-11-26 18:58:24 +00:00
return glConfig . nativeScreenWidth ;
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idRenderSystemLocal : : GetHeight
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
int idRenderSystemLocal : : GetHeight ( ) const
{
2024-11-26 20:18:42 +00:00
// do something similar in case the VR API requires it
/*
2012-11-28 15:47:07 +00:00
if ( glConfig . stereo3Dmode = = STEREO3D_HDMI_720 )
{
2012-11-26 18:58:24 +00:00
return 720 ;
}
extern idCVar stereoRender_warp ;
2012-11-28 15:47:07 +00:00
if ( glConfig . stereo3Dmode = = STEREO3D_SIDE_BY_SIDE & & stereoRender_warp . GetBool ( ) )
{
2012-11-26 18:58:24 +00:00
// for the Rift, render a square aspect view that will be symetric for the optics
return glConfig . nativeScreenWidth > > 1 ;
}
2024-11-26 20:18:42 +00:00
*/
return glConfig . nativeScreenHeight ;
}
// RB: return swap chain width
int idRenderSystemLocal : : GetNativeWidth ( ) const
{
return glConfig . nativeScreenWidth ;
}
// RB: return swap chain height
int idRenderSystemLocal : : GetNativeHeight ( ) const
{
2012-11-26 18:58:24 +00:00
return glConfig . nativeScreenHeight ;
}
2024-11-26 20:18:42 +00:00
// RB end
2012-11-26 18:58:24 +00:00
2013-09-21 12:12:42 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idRenderSystemLocal : : GetVirtualWidth
= = = = = = = = = = = = = = = = = = = = = = = =
*/
int idRenderSystemLocal : : GetVirtualWidth ( ) const
{
2021-02-25 18:36:59 +00:00
// jmarshall - never strech
//if( r_useVirtualScreenResolution.GetBool() )
//{
// return SCREEN_WIDTH;
//}
// jmarshall end
2024-08-05 20:59:28 +00:00
return glConfig . nativeScreenWidth / 2 ;
2013-09-21 12:12:42 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idRenderSystemLocal : : GetVirtualHeight
= = = = = = = = = = = = = = = = = = = = = = = =
*/
int idRenderSystemLocal : : GetVirtualHeight ( ) const
{
2021-02-25 18:36:59 +00:00
// jmarshall - never strech
//if( r_useVirtualScreenResolution.GetBool() )
//{
// return SCREEN_HEIGHT;
//}
// jmarshall end
2024-08-05 20:59:28 +00:00
return glConfig . nativeScreenHeight / 2 ;
2013-09-21 12:12:42 +00:00
}
2012-11-26 18:58:24 +00:00
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idRenderSystemLocal : : GetPixelAspect
= = = = = = = = = = = = = = = = = = = = = = = =
*/
2012-11-28 15:47:07 +00:00
float idRenderSystemLocal : : GetPixelAspect ( ) const
{
2024-11-26 20:18:42 +00:00
/*
2012-11-28 15:47:07 +00:00
switch ( glConfig . stereo3Dmode )
{
case STEREO3D_SIDE_BY_SIDE_COMPRESSED :
return glConfig . pixelAspect * 2.0f ;
case STEREO3D_TOP_AND_BOTTOM_COMPRESSED :
case STEREO3D_INTERLACED :
return glConfig . pixelAspect * 0.5f ;
default :
return glConfig . pixelAspect ;
2012-11-26 18:58:24 +00:00
}
2024-11-26 20:18:42 +00:00
*/
return glConfig . pixelAspect ;
2012-11-26 18:58:24 +00:00
}
/*
= = = = = = = = = = = = = = = = = = = = = = = =
idRenderSystemLocal : : GetPhysicalScreenWidthInCentimeters
This is used to calculate stereoscopic screen offset for a given interocular distance .
= = = = = = = = = = = = = = = = = = = = = = = =
*/
idCVar r_forceScreenWidthCentimeters ( " r_forceScreenWidthCentimeters " , " 0 " , CVAR_RENDERER | CVAR_ARCHIVE , " Override screen width returned by hardware " ) ;
2012-11-28 15:47:07 +00:00
float idRenderSystemLocal : : GetPhysicalScreenWidthInCentimeters ( ) const
{
if ( r_forceScreenWidthCentimeters . GetFloat ( ) > 0 )
{
2012-11-26 18:58:24 +00:00
return r_forceScreenWidthCentimeters . GetFloat ( ) ;
}
return glConfig . physicalScreenWidthInCentimeters ;
}