Skip to content

Commit

Permalink
Implement SDLGPUDriver
Browse files Browse the repository at this point in the history
Co-authored-by: Ethan Lee <[email protected]>
Co-authored-by: Caleb Cornett <[email protected]>
  • Loading branch information
3 people committed Apr 11, 2024
1 parent 1cb3c7d commit 4d27fae
Show file tree
Hide file tree
Showing 6 changed files with 5,118 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ add_definitions(
-DFNA3D_DRIVER_VULKAN
-DFNA3D_DRIVER_OPENGL
)
if(BUILD_SDL3)
add_definitions(-DFNA3D_DRIVER_SDL)
endif()
add_definitions(
-DMOJOSHADER_NO_VERSION_INCLUDE
-DMOJOSHADER_USE_SDL_STDLIB
Expand Down Expand Up @@ -101,6 +104,7 @@ add_library(FNA3D
src/FNA3D.c
src/FNA3D_Driver_D3D11.c
src/FNA3D_Driver_OpenGL.c
src/FNA3D_Driver_SDL.c
src/FNA3D_Driver_Vulkan.c
src/FNA3D_Image.c
src/FNA3D_CommandBuffer.c
Expand Down
13 changes: 8 additions & 5 deletions replay/replay.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ static uint8_t replay(const char *filename, uint8_t forceDebugMode)
#define READ(val) SDL_ReadIO(ops, &val, sizeof(val))

SDL_WindowFlags flags;
const SDL_DisplayMode *mode;
SDL_IOStream *ops;
SDL_Event evt;
uint8_t mark, run;
Expand Down Expand Up @@ -280,15 +281,17 @@ static uint8_t replay(const char *filename, uint8_t forceDebugMode)
READ(debugMode);

/* Create a window alongside the device */
flags = FNA3D_PrepareWindowAttributes();
flags = FNA3D_PrepareWindowAttributes() | SDL_WINDOW_HIGH_PIXEL_DENSITY;
if (presentationParameters.isFullScreen)
{
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
}
mode = SDL_GetDesktopDisplayMode(SDL_GetPrimaryDisplay());
SDL_Log("Pixel density is %f", mode->pixel_density);
presentationParameters.deviceWindowHandle = SDL_CreateWindow(
"FNA3D Replay",
presentationParameters.backBufferWidth,
presentationParameters.backBufferHeight,
(int) (presentationParameters.backBufferWidth / mode->pixel_density),
(int) (presentationParameters.backBufferHeight / mode->pixel_density),
flags
);
device = FNA3D_CreateDevice(&presentationParameters, debugMode || forceDebugMode);
Expand Down Expand Up @@ -690,8 +693,8 @@ static uint8_t replay(const char *filename, uint8_t forceDebugMode)
);
SDL_SetWindowSize(
presentationParameters.deviceWindowHandle,
presentationParameters.backBufferWidth,
presentationParameters.backBufferHeight
(int) (presentationParameters.backBufferWidth / mode->pixel_density),
(int) (presentationParameters.backBufferHeight / mode->pixel_density)
);
FNA3D_ResetBackbuffer(device, &presentationParameters);
break;
Expand Down
3 changes: 3 additions & 0 deletions src/FNA3D.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
/* Drivers */

static const FNA3D_Driver *drivers[] = {
#if FNA3D_DRIVER_SDL
&SDLGPUDriver,
#endif
#if FNA3D_DRIVER_D3D11
&D3D11Driver,
#endif
Expand Down
1 change: 1 addition & 0 deletions src/FNA3D_Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,7 @@ typedef struct FNA3D_Driver
FNA3D_SHAREDINTERNAL FNA3D_Driver VulkanDriver;
FNA3D_SHAREDINTERNAL FNA3D_Driver D3D11Driver;
FNA3D_SHAREDINTERNAL FNA3D_Driver OpenGLDriver;
FNA3D_SHAREDINTERNAL FNA3D_Driver SDLGPUDriver;
FNA3D_SHAREDINTERNAL FNA3D_Driver GNMXDriver;

#endif /* FNA3D_DRIVER_H */
Expand Down
Loading

0 comments on commit 4d27fae

Please sign in to comment.