Skip to content

Commit

Permalink
Add support for using WARP software rasterizer with the D3D11 backend (
Browse files Browse the repository at this point in the history
  • Loading branch information
kg committed Oct 1, 2023
1 parent 95ee2be commit 71073a3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/FNA3D_Driver_D3D11.c
Expand Up @@ -4848,6 +4848,10 @@ static uint8_t D3D11_PrepareWindowAttributes(uint32_t *flags)
};
HRESULT res;

const uint32_t driverType = SDL_GetHintBoolean("FNA3D_D3D11_USE_WARP", SDL_FALSE)
? D3D_DRIVER_TYPE_HARDWARE
: D3D_DRIVER_TYPE_WARP;

#ifdef FNA3D_DXVK_NATIVE
const char *forceDriver = SDL_GetHint("FNA3D_FORCE_DRIVER");
if ((forceDriver == NULL) || (SDL_strcmp(forceDriver, "D3D11") != 0))
Expand Down Expand Up @@ -4885,7 +4889,7 @@ static uint8_t D3D11_PrepareWindowAttributes(uint32_t *flags)

res = D3D11CreateDeviceFunc(
NULL,
D3D_DRIVER_TYPE_HARDWARE,
driverType,
NULL,
D3D11_CREATE_DEVICE_BGRA_SUPPORT,
levels,
Expand All @@ -4901,7 +4905,7 @@ static uint8_t D3D11_PrepareWindowAttributes(uint32_t *flags)
FNA3D_LogWarn("Creating device with feature level 11_1 failed. Lowering feature level.", res);
res = D3D11CreateDeviceFunc(
NULL,
D3D_DRIVER_TYPE_HARDWARE,
driverType,
NULL,
D3D11_CREATE_DEVICE_BGRA_SUPPORT,
&levels[1],
Expand Down Expand Up @@ -5110,6 +5114,10 @@ static FNA3D_Device* D3D11_CreateDevice(
int32_t i;
HRESULT res;

const uint32_t driverType = SDL_GetHintBoolean("FNA3D_D3D11_USE_WARP", SDL_FALSE)
? D3D_DRIVER_TYPE_UNKNOWN /* Must be UNKNOWN if adapter is non-null according to spec */
: D3D_DRIVER_TYPE_WARP;

/* Allocate and zero out the renderer */
renderer = (D3D11Renderer*) SDL_malloc(sizeof(D3D11Renderer));
SDL_memset(renderer, '\0', sizeof(D3D11Renderer));
Expand Down Expand Up @@ -5177,8 +5185,8 @@ static FNA3D_Device* D3D11_CreateDevice(
for (i = 0; i < 2; i += 1)
{
res = D3D11CreateDeviceFunc(
(IDXGIAdapter*) renderer->adapter,
D3D_DRIVER_TYPE_UNKNOWN, /* Must be UNKNOWN if adapter is non-null according to spec */
(driverType == D3D_DRIVER_TYPE_WARP) ? NULL : (IDXGIAdapter*) renderer->adapter,
driverType,
NULL,
flags,
&levels[i],
Expand Down

0 comments on commit 71073a3

Please sign in to comment.