Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for using WARP software rasterizer with the D3D11 backend #178

Merged
merged 2 commits into from
Oct 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/FNA3D_Driver_D3D11.c
Original file line number Diff line number Diff line change
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
Loading