Skip to content

Commit

Permalink
Use Direct 3D 11 if vid_scaleapi CVAR is direct3d
Browse files Browse the repository at this point in the history
(While reverting previous changes to `vid_scaleapi` CVAR.) This change gives a significant jump in FPS.
  • Loading branch information
bradharding committed Oct 12, 2023
1 parent 7dcd394 commit ec7fc46
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 24 deletions.
12 changes: 0 additions & 12 deletions src/c_autocomplete.c
Original file line number Diff line number Diff line change
Expand Up @@ -6078,20 +6078,12 @@ autocomplete_t autocompletelist[] =
#if defined(_WIN32)
{ "if vid_scaleapi \"direct3d\" ", DOOM1AND2 },
{ "if vid_scaleapi \"direct3d\" then ", DOOM1AND2 },
{ "if vid_scaleapi \"direct3d11\" ", DOOM1AND2 },
{ "if vid_scaleapi \"direct3d11\" then ", DOOM1AND2 },
{ "if vid_scaleapi \"direct3d12\" ", DOOM1AND2 },
{ "if vid_scaleapi \"direct3d12\" then ", DOOM1AND2 },
{ "if vid_scaleapi \"opengl\" ", DOOM1AND2 },
{ "if vid_scaleapi \"opengl\" then ", DOOM1AND2 },
{ "if vid_scaleapi \"software\" ", DOOM1AND2 },
{ "if vid_scaleapi \"software\" then ", DOOM1AND2 },
{ "if vid_scaleapi direct3d ", DOOM1AND2 },
{ "if vid_scaleapi direct3d then ", DOOM1AND2 },
{ "if vid_scaleapi direct3d11 ", DOOM1AND2 },
{ "if vid_scaleapi direct3d11 then ", DOOM1AND2 },
{ "if vid_scaleapi direct3d12 ", DOOM1AND2 },
{ "if vid_scaleapi direct3d12 then ", DOOM1AND2 },
{ "if vid_scaleapi opengl ", DOOM1AND2 },
{ "if vid_scaleapi opengl then ", DOOM1AND2 },
{ "if vid_scaleapi software ", DOOM1AND2 },
Expand Down Expand Up @@ -7969,13 +7961,9 @@ autocomplete_t autocompletelist[] =
{ "vid_scaleapi ", DOOM1AND2 },
#if defined(_WIN32)
{ "vid_scaleapi \"direct3d\"", DOOM1AND2 },
{ "vid_scaleapi \"direct3d11\"", DOOM1AND2 },
{ "vid_scaleapi \"direct3d12\"", DOOM1AND2 },
{ "vid_scaleapi \"opengl\"", DOOM1AND2 },
{ "vid_scaleapi \"software\"", DOOM1AND2 },
{ "vid_scaleapi direct3d", DOOM1AND2 },
{ "vid_scaleapi direct3d11", DOOM1AND2 },
{ "vid_scaleapi direct3d12", DOOM1AND2 },
{ "vid_scaleapi opengl", DOOM1AND2 },
{ "vid_scaleapi software", DOOM1AND2 },
#else
Expand Down
3 changes: 1 addition & 2 deletions src/c_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -982,8 +982,7 @@ consolecmd_t consolecmds[] =
"Toggles using the pillarboxes either side of the screen for certain effects when not in widescreen mode."),
#if defined(_WIN32)
CVAR_STR(vid_scaleapi, "", "", vid_scaleapi_cvar_func1, vid_scaleapi_cvar_func2, CF_NONE,
"The API used to scale each frame (" BOLD("\"direct3d\"") ", " BOLD("\"direct3d11\"") ", "
BOLD("\"direct3d12\"") ", " BOLD("\"opengl\"") " or " BOLD("\"software\"") ")."),
"The API used to scale each frame (" BOLD("\"direct3d\"") ", " BOLD("\"opengl\"") " or " BOLD("\"software\"") ")."),
#else
CVAR_STR(vid_scaleapi, "", "", vid_scaleapi_cvar_func1, vid_scaleapi_cvar_func2, CF_NONE,
"The API used to scale each frame (" BOLD("\"opengl\"") ", " BOLD("\"opengles\"") ", " BOLD("\"opengles2\"") " or "
Expand Down
14 changes: 6 additions & 8 deletions src/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,9 @@ static void SetVideoMode(const bool createwindow, const bool output)
SDL_SetHintWithPriority(SDL_HINT_RENDER_SCALE_QUALITY, vid_scalefilter, SDL_HINT_OVERRIDE);
}

SDL_SetHintWithPriority(SDL_HINT_RENDER_DRIVER, vid_scaleapi, SDL_HINT_OVERRIDE);
SDL_SetHintWithPriority(SDL_HINT_RENDER_DRIVER,
(M_StringCompare(vid_scaleapi, vid_scaleapi_direct3d) ? "direct3d11" : vid_scaleapi),
SDL_HINT_OVERRIDE);

software = M_StringCompare(vid_scaleapi, vid_scaleapi_software);

Expand Down Expand Up @@ -1466,7 +1468,7 @@ static void SetVideoMode(const bool createwindow, const bool output)
vid_scaleapi = vid_scaleapi_direct3d;
M_SaveCVARs();

SDL_SetHintWithPriority(SDL_HINT_RENDER_DRIVER, vid_scaleapi, SDL_HINT_OVERRIDE);
SDL_SetHintWithPriority(SDL_HINT_RENDER_DRIVER, "direct3d11", SDL_HINT_OVERRIDE);

if (output)
C_Output("This scaling is now done using hardware acceleration with "
Expand All @@ -1488,16 +1490,12 @@ static void SetVideoMode(const bool createwindow, const bool output)
}
}
#if defined(_WIN32)
else if (M_StringCompare(rendererinfo.name, vid_scaleapi_direct3d)
|| M_StringCompare(rendererinfo.name, vid_scaleapi_direct3d11)
|| M_StringCompare(rendererinfo.name, vid_scaleapi_direct3d12))
else if (M_StringCompare(rendererinfo.name, vid_scaleapi_direct3d))
{
if (output)
C_Output("This scaling is done using hardware acceleration with " ITALICS("Direct3D."));

if (!M_StringCompare(vid_scaleapi, vid_scaleapi_direct3d)
&& !M_StringCompare(vid_scaleapi, vid_scaleapi_direct3d11)
&& !M_StringCompare(vid_scaleapi, vid_scaleapi_direct3d12))
if (!M_StringCompare(vid_scaleapi, vid_scaleapi_direct3d))
{
vid_scaleapi = vid_scaleapi_direct3d;
M_SaveCVARs();
Expand Down
2 changes: 0 additions & 2 deletions src/m_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,6 @@ enum

#if defined(_WIN32)
#define vid_scaleapi_direct3d "direct3d"
#define vid_scaleapi_direct3d11 "direct3d11"
#define vid_scaleapi_direct3d12 "direct3d12"
#endif
#define vid_scaleapi_opengl "opengl"
#if !defined(_WIN32)
Expand Down

0 comments on commit ec7fc46

Please sign in to comment.