DX12 backend is turned off by default. Can be enabled with ENABLE_DX12.
This commit is contained in:
parent
e86e65f173
commit
f38011533d
14
README.md
14
README.md
|
|
@ -8,22 +8,24 @@ This repository contains updated version of the original Q3 codebase with reorga
|
|||
* Build `visual-studio/quake3.sln` solution.
|
||||
* Copy `quake3-ke.exe` to your local Quake-III-Arena installation folder.
|
||||
|
||||
## Vulkan and DX12 support
|
||||
## Vulkan support
|
||||
Vulkan backend provides the same graphics features as original OpenGL-based one including customization via r_xxx cvars and debug visualization.
|
||||
|
||||
Initially DirectX 12 backend was an exercise to learn this graphics API. It turned out the implementation is quite concise, so it was merged into the main branch. There is an option to compile the project without DX12 backend. For this, uncomment DISABLE_DX12 macro in dx.h header.
|
||||
## DX12 support
|
||||
DirectX 12 backend implementation is provided mostly for educational purposes and is not included in the prebuild binaries. It can be enabled by uncommenting ENABLED_DX12 in dx.h header and recompiling the project.
|
||||
|
||||
#### New cvars:
|
||||
* **r_renderAPI** - 3D API to use: 0 - OpenGL, 1 - Vulkan, 2 - DX12. Requires vid_restart.
|
||||
* **r_renderAPI** - 3D API to use. Requires vid_restart.
|
||||
* 0 - OpenGL
|
||||
* 1 - Vulkan
|
||||
* 2 - DX12 (if enabled, see above).
|
||||
|
||||
* **r_twinMode** - Debug feature to compare rendering output between OpenGL/Vulkan/DX12 APIs. Requires vid_restart.
|
||||
* r_twinMode=1 : one additional window is created. If the main window uses graphics API defined by `r_renderAPI` then the additional window will use graphics API with index `(r_renderAPI+1)%3`
|
||||
* r_twinMode=2 : two additional windows are created and all 3 graphics APIs are active simultaneously.
|
||||
|
||||
#### Additional information:
|
||||
* Q: How to start game with vulkan support? A: `quake3-ke.exe +set r_renderAPI 1`.
|
||||
* Q: How to enable vulkan support from Q3 console? A: `\r_renderAPI 1` then `\vid_restart`.
|
||||
* Q: How to enable twin mode from Q3 console? A: `\r_twinMode 1` or `\r_twinMode 2` then `\vid_restart`.
|
||||
* Q: How to enable twin mode from Q3 console? A: `\r_twinMode 1` or `\r_twinMode 1` then `\vid_restart`.
|
||||
* Q: How to check that Vulkan backend is really active? A: `gfxinfo` console command reports information about active rendering backend.
|
||||
|
||||
## Visual Studio
|
||||
|
|
|
|||
|
|
@ -494,22 +494,16 @@ static HWND create_twin_window(int width, int height, RenderApi render_api)
|
|||
cvar_t* vid_ypos = ri.Cvar_Get ("vid_ypos", "", 0);
|
||||
int x, y;
|
||||
|
||||
if (r_twinMode->integer == 1) { // two windows
|
||||
x = vid_xpos->integer + width + 5; // offset to the right of the main window
|
||||
y = vid_ypos->integer;
|
||||
} else { // three windows
|
||||
bool first_twin_window =
|
||||
bool first_twin_window =
|
||||
(get_render_api() != RENDER_API_GL && render_api == RENDER_API_GL) ||
|
||||
(get_render_api() == RENDER_API_GL && render_api == RENDER_API_VK);
|
||||
|
||||
if (first_twin_window) {
|
||||
x = vid_xpos->integer + width + 5;
|
||||
y = vid_ypos->integer;
|
||||
} else {
|
||||
x = vid_xpos->integer + 2*width + 10;
|
||||
y = vid_ypos->integer;
|
||||
}
|
||||
|
||||
if (first_twin_window) {
|
||||
x = vid_xpos->integer + width + 5;
|
||||
y = vid_ypos->integer;
|
||||
} else {
|
||||
x = vid_xpos->integer + 2*width + 10;
|
||||
y = vid_ypos->integer;
|
||||
}
|
||||
|
||||
int desktop_width = GetDesktopWidth();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include <chrono>
|
||||
#include <functional>
|
||||
|
||||
#ifndef DISABLE_DX12
|
||||
#ifdef ENABLE_DX12
|
||||
|
||||
#include "D3d12.h"
|
||||
#include "DXGI1_4.h"
|
||||
|
|
@ -1485,7 +1485,7 @@ void dx_end_frame() {
|
|||
DX_CHECK(dx.swapchain->Present(0, 0));
|
||||
}
|
||||
|
||||
#else // DISABLE_DX12
|
||||
#else // ENABLE_DX12
|
||||
|
||||
void dx_initialize() {}
|
||||
void dx_shutdown() {}
|
||||
|
|
@ -1503,4 +1503,4 @@ void dx_shade_geometry(ID3D12PipelineState* pipeline, bool multitexture, Vk_Dept
|
|||
void dx_begin_frame() {}
|
||||
void dx_end_frame() {}
|
||||
|
||||
#endif // DISABLE_DX12
|
||||
#endif // ENABLE_DX12
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
// Uncomment the following line to disable DX12 backend
|
||||
//#define DISABLE_DX12
|
||||
// Uncomment the following line to enable DX12 backend
|
||||
//#define ENABLE_DX12
|
||||
|
||||
struct ID3D12CommandAllocator;
|
||||
struct ID3D12GraphicsCommandList;
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ RenderApi get_render_api() {
|
|||
else if (r_renderAPI->integer == 1)
|
||||
return RENDER_API_VK;
|
||||
else if (r_renderAPI->integer == 2)
|
||||
#ifndef DISABLE_DX12
|
||||
#ifdef ENABLE_DX12
|
||||
return RENDER_API_DX;
|
||||
#else
|
||||
return RENDER_API_GL; // use default (GL) if dx12 is disabled
|
||||
|
|
@ -204,16 +204,14 @@ static void InitRenderAPI( void )
|
|||
//
|
||||
if ( glConfig.vidWidth == 0 )
|
||||
{
|
||||
#ifdef DISABLE_DX12
|
||||
#ifndef ENABLE_DX12
|
||||
if (r_renderAPI->integer == 2) {
|
||||
ri.Printf(PRINT_WARNING, "DirectX 12 backend is disabled (code was compiled with DISABLE_DX12). OpenGL backend will be used instead.\n");
|
||||
ri.Printf(PRINT_WARNING, "DirectX 12 backend is disabled (code was compiled without ENABLE_DX12). OpenGL backend will be used instead.\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
// OpenGL
|
||||
if (get_render_api() == RENDER_API_GL ||
|
||||
r_twinMode->integer == 1 && get_render_api() == RENDER_API_DX ||
|
||||
r_twinMode->integer == 2)
|
||||
if (get_render_api() == RENDER_API_GL || r_twinMode->integer)
|
||||
{
|
||||
GLimp_Init();
|
||||
|
||||
|
|
@ -225,19 +223,15 @@ static void InitRenderAPI( void )
|
|||
}
|
||||
|
||||
// VULKAN
|
||||
if (get_render_api() == RENDER_API_VK ||
|
||||
r_twinMode->integer == 1 && get_render_api() == RENDER_API_GL ||
|
||||
r_twinMode->integer == 2)
|
||||
if (get_render_api() == RENDER_API_VK || r_twinMode->integer)
|
||||
{
|
||||
vk_imp_init();
|
||||
vk_initialize();
|
||||
}
|
||||
|
||||
// DX12
|
||||
#ifndef DISABLE_DX12
|
||||
if (get_render_api() == RENDER_API_DX ||
|
||||
r_twinMode->integer == 1 && get_render_api() == RENDER_API_VK ||
|
||||
r_twinMode->integer == 2)
|
||||
#ifdef ENABLE_DX12
|
||||
if (get_render_api() == RENDER_API_DX || r_twinMode->integer)
|
||||
{
|
||||
dx_imp_init();
|
||||
dx_initialize();
|
||||
|
|
|
|||
|
|
@ -958,12 +958,7 @@ RenderApi get_render_api();
|
|||
//
|
||||
extern cvar_t *r_renderAPI; // 3D API to use: 0 - OpenGL, 1 - Vulkan, 2 - DX12
|
||||
|
||||
extern cvar_t *r_twinMode; // Debug feature to compare rendering output between OpenGL/Vulkan/DX12 APIs.
|
||||
// Possible values:
|
||||
// r_twinMode=1 : one additional window is created. If the main window uses graphics API
|
||||
// defined by r_renderAPI then the additional window will use graphics API with index (r_renderAPI+1)%3
|
||||
//
|
||||
// r_twinMode=2 : two additional windows are created and all 3 graphics APIs are active simultaneously.
|
||||
extern cvar_t *r_twinMode; // Debug feature to compare rendering output between OpenGL/Vulkan/DX12 APIs
|
||||
|
||||
extern cvar_t *r_railWidth;
|
||||
extern cvar_t *r_railCoreWidth;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user