Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2803288
Update .gitignore
alfonsmagd Aug 8, 2025
d3c3843
Add D3D11 support and related functionality
alfonsmagd Sep 11, 2025
9a55709
Merge branch 'aap:master' into d3d11_integration_backend
alfonsmagd Sep 11, 2025
60a23a7
Resolve Integration Interface with D3D11
alfonsmagd Mar 28, 2026
e5f7c21
Add initial stub for Direct3D 11 device support
alfonsmagd Mar 29, 2026
58c914b
Add initial D3D11 backend scaffolding
alfonsmagd Apr 23, 2026
f6900ea
resolve palette to SRV concept
alfonsmagd Jul 11, 2026
71738a0
Add D3D11 Im3D setup and transform
alfonsmagd Jul 11, 2026
9cecca5
Add D3D11 Im3D primitive rendering
alfonsmagd Jul 11, 2026
6e53f36
Complete D3D11 immediate rendering
alfonsmagd Jul 12, 2026
e5af439
Add D3D11 managed-style index buffers
alfonsmagd Jul 16, 2026
39e4f71
Add D3D11 default atomic rendering
alfonsmagd Jul 19, 2026
6a32f01
Align D3D11 rendering with D3D9 conventions
alfonsmagd Jul 19, 2026
c4d5062
Cache D3D11 pipeline bindings
alfonsmagd Jul 20, 2026
cc2ab71
Complete D3D11 subraster clearing
alfonsmagd Jul 23, 2026
70269b1
Add D3D11 vertex lighting
alfonsmagd Jul 23, 2026
0bcb91d
Match D3D9 Im3D alpha coverage
alfonsmagd Jul 23, 2026
8a23389
Document D3D11 Im3D pixel-center correction
alfonsmagd Jul 23, 2026
c5e5771
Clarify D3D11 Im3D shader ownership
alfonsmagd Jul 23, 2026
1d6ff81
update renaming color
alfonsmagd Jul 23, 2026
966bd95
Add D3D11 native texture conversion
alfonsmagd Jul 24, 2026
2ce5b27
Format d3d11 device and refactor Raster d3d11 mip map generation
alfonsmagd Jul 24, 2026
a2a1165
Expand D3D11 geometry and skin support
alfonsmagd Jul 26, 2026
70b4858
Add D3D11 MatFX environment rendering
alfonsmagd Jul 26, 2026
2f3473d
Match D3D11 light limit to D3D9
alfonsmagd Jul 26, 2026
a8ff2ab
Enumerate D3D11 display modes
alfonsmagd Jul 26, 2026
ffec29d
Complete D3D11 texture streaming and camera readback
alfonsmagd Jul 28, 2026
032c848
Add D3D11 Premake and CI support
alfonsmagd Jul 28, 2026
95acb58
Add correct videomodelist
alfonsmagd Jul 28, 2026
b8211ac
Keep Premake D3D11 support minimal
alfonsmagd Jul 28, 2026
98e3503
Merge pull request #1 from alfonsmagd/d3d11_integration_backend
alfonsmagd Jul 28, 2026
2f6cc58
Remove librw architecture mind map
alfonsmagd Jul 28, 2026
ca1d129
Merge branch 'aap:master' into master
alfonsmagd Jul 28, 2026
e2d4a8c
Restore generic engine device naming
alfonsmagd Jul 28, 2026
407c56e
Keep D3D9 raster declarations scoped
alfonsmagd Jul 28, 2026
7b8558b
Combine upstream Premake options with D3D11
alfonsmagd Jul 28, 2026
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
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
matrix:
case:
- { name: 'Windows (DirectX 9)', os: 'windows-latest', platform: 'D3D9' }
- { name: 'Windows (DirectX 11)', os: 'windows-latest', platform: 'D3D11' }
- { name: 'Windows (GL3, glfw)', os: 'windows-latest', platform: 'GL3', gl3_gfxlib: 'GLFW' }
- { name: 'Windows (GL3, SDL2)', os: 'windows-latest', platform: 'GL3', gl3_gfxlib: 'SDL2', sdl-version: '2-latest' }
- { name: 'Windows (GL3, SDL3)', os: 'windows-latest', platform: 'GL3', gl3_gfxlib: 'SDL3', sdl-version: '3-latest' }
Expand Down
55 changes: 46 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,47 @@
/bin
/build
/obj
/lib
/output
/.vs
librw.vcxproj.user
librw.VC.db
librw.VC.VC.opendb
/bin
/build
/build-*/
/obj
/lib
/output
/.vs

# CMake generated files
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
install_manifest.txt
CTestTestfile.cmake
Testing/
_deps/

# Visual Studio and MSVC build artifacts
*.obj
*.o
*.pch
*.pdb
*.ipch
*.ilk
*.idb
*.tlog
*.recipe
*.lastbuildstate
*.suo
*.user
*.VC.db
*.VC.opendb
*.vsidx

# Compiled binaries and shader output
*.bin
*.cso
*.exe
*.dll
*.lib
*.exp

librw.vcxproj.user
librw.VC.db
librw.VC.VC.opendb
imgui.ini
/glfw
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set(librw_AUTHOR aap)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

if(WIN32)
set(LIBRW_PLATFORMS "NULL" "GL3" "D3D9")
set(LIBRW_PLATFORMS "NULL" "GL3" "D3D9" "D3D11")
set(LIBRW_PLATFORM_GL3_REQUIRES_OPENGL ON)
elseif(NINTENDO_SWITCH)
set(LIBRW_PLATFORMS "NULL" "GL3")
Expand Down Expand Up @@ -134,6 +134,8 @@ if(LIBRW_INSTALL)
endif()
elseif(LIBRW_PLATFORM_D3D9)
set(platform "-d3d9")
elseif(LIBRW_PLATFORM_D3D11)
set(platform "-d3d11")
endif()
if(NOT LIBRW_PLATFORM_PS2)
if(WIN32)
Expand Down
3 changes: 3 additions & 0 deletions cmake/ShaderSource.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
static const char @SHADER_VARIABLE@[] = R"librw_shader(
@SHADER_SOURCE@
)librw_shader";
58 changes: 53 additions & 5 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,51 @@ newoption {
default = "../SDL3-3.2.22",
}

local d3d11Shaders = {
"clear_VS_d11",
"clear_PS_d11",
"im2d_VS_d11",
"im2d_PS_d11",
"im3d_VS_d11",
"im3d_PS_d11",
"im3d_tex_PS_d11",
"default_VS_d11",
"default_PS_d11",
"skin_VS_d11",
"matfx_env_VS_d11",
"matfx_env_PS_d11",
}

local d3d11GeneratedDir = path.join(_SCRIPT_DIR, "build/generated")

local function generateD3D11ShaderHeaders()
os.mkdir(d3d11GeneratedDir)
for _, shaderName in ipairs(d3d11Shaders) do
local input = assert(io.open(path.join(
_SCRIPT_DIR, "src/d3d/shaders", shaderName .. ".hlsl"), "rb"))
local source = input:read("*all")
input:close()

local output = assert(io.open(path.join(
d3d11GeneratedDir, shaderName .. ".h"), "wb"))
output:write("static const char ", shaderName,
"_source[] = R\"librw_shader(\n", source,
"\n)librw_shader\";\n")
output:close()
end
end

generateD3D11ShaderHeaders()

workspace "librw"
location "build"
language "C++"

configurations { "Release", "Debug" }
filter { "system:windows" }
configurations { "ReleaseStatic" }
platforms { "win-x86-null", "win-x86-gl3", "win-x86-d3d9",
"win-amd64-null", "win-amd64-gl3", "win-amd64-d3d9" }
platforms { "win-x86-null", "win-x86-gl3", "win-x86-d3d9", "win-x86-d3d11",
"win-amd64-null", "win-amd64-gl3", "win-amd64-d3d9", "win-amd64-d3d11" }
filter { "system:linux" }
platforms { "linux-x86-null", "linux-x86-gl3",
"linux-amd64-null", "linux-amd64-gl3",
Expand Down Expand Up @@ -79,6 +115,8 @@ workspace "librw"
end
filter { "platforms:*d3d9" }
defines { "RW_D3D9" }
filter { "platforms:*d3d11" }
defines { "RW_D3D11" }
filter { "platforms:ps2" }
defines { "RW_PS2" }
toolset "gcc"
Expand Down Expand Up @@ -128,11 +166,17 @@ project "librw"
files { "src/*/*.*" }
filter { "platforms:*gl3" }
files { "src/gl/glad/*.*" }
filter { "platforms:*d3d11" }
includedirs { d3d11GeneratedDir }
files { "src/d3d/shaders/*_d11.hlsl" }
filter { "files:**.hlsl" }
buildaction "None"
filter {}

project "dumprwtree"
kind "ConsoleApp"
targetdir (Bindir)
removeplatforms { "*gl3", "*d3d9", "ps2" }
removeplatforms { "*gl3", "*d3d9", "*d3d11", "ps2" }
files { "tools/dumprwtree/*" }
includedirs { "." }
libdirs { Libdir }
Expand Down Expand Up @@ -169,6 +213,10 @@ function findlibs()
links { "gdi32", "d3d9" }
filter { "platforms:*d3d9", "action:vs*" }
links { "Xinput9_1_0" }
filter { "platforms:*d3d11" }
links { "gdi32", "d3d11", "dxgi", "d3dcompiler" }
filter { "platforms:*d3d11", "action:vs*" }
links { "Xinput9_1_0" }
filter {}
end

Expand Down Expand Up @@ -270,13 +318,13 @@ project "ska2anm"
libdirs { Libdir }
links { "librw" }
findlibs()
removeplatforms { "*gl3", "*d3d9", "*ps2" }
removeplatforms { "*gl3", "*d3d9", "*d3d11", "*ps2" }

project "ps2test"
kind "ConsoleApp"
targetdir (Bindir)
vucode()
removeplatforms { "*gl3", "*d3d9", "*null" }
removeplatforms { "*gl3", "*d3d9", "*d3d11", "*null" }
targetextension '.elf'
includedirs { "." }
files { "tools/ps2test/*.cpp",
Expand Down
1 change: 1 addition & 0 deletions rw.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "src/d3d/rwd3d.h"
#include "src/d3d/rwd3d8.h"
#include "src/d3d/rwd3d9.h"
#include "src/d3d/rwd3d11.h"
#include "src/gl/rwwdgl.h"
#include "src/gl/rwgl3.h"
#include "src/gl/rwgl3shader.h"
Expand Down
2 changes: 1 addition & 1 deletion skeleton/win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using namespace sk;
using namespace rw;

#ifdef RW_D3D9
#if defined(RW_D3D9) || defined(RW_D3D11)

#ifndef VK_OEM_NEC_EQUAL
#define VK_OEM_NEC_EQUAL 0x92
Expand Down
57 changes: 57 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ add_library(librw
d3d/d3ddevice.cpp
d3d/d3dimmed.cpp
d3d/d3drender.cpp
d3d/d3d11.cpp
d3d/d3d11device.cpp
d3d/d3d11matfx.cpp
d3d/d3d11skin.cpp
d3d/d3d11render.cpp
d3d/rwd3d11.h
d3d/rwd3d8.h
d3d/rwd3d9.h
d3d/rwd3d.h
Expand Down Expand Up @@ -97,6 +103,48 @@ add_library(librw
)
add_library(librw::librw ALIAS librw)

if(LIBRW_PLATFORM_D3D11)
set(D3D11_SHADER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/d3d/shaders")
set(D3D11_GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
file(MAKE_DIRECTORY "${D3D11_GENERATED_DIR}")

set(D3D11_SHADERS
clear_VS_d11
clear_PS_d11
im2d_VS_d11
im2d_PS_d11
im3d_VS_d11
im3d_PS_d11
im3d_tex_PS_d11
default_VS_d11
default_PS_d11
skin_VS_d11
matfx_env_VS_d11
matfx_env_PS_d11
)

foreach(SHADER_NAME IN LISTS D3D11_SHADERS)
set(SHADER_PATH "${D3D11_SHADER_DIR}/${SHADER_NAME}.hlsl")
list(APPEND D3D11_SHADER_SOURCES "${SHADER_PATH}")
file(READ "${SHADER_PATH}" SHADER_SOURCE)
set(SHADER_VARIABLE "${SHADER_NAME}_source")
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/ShaderSource.h.in"
"${D3D11_GENERATED_DIR}/${SHADER_NAME}.h"
@ONLY
)
endforeach()

set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
${D3D11_SHADER_SOURCES}
)
target_sources(librw PRIVATE ${D3D11_SHADER_SOURCES})
set_source_files_properties(${D3D11_SHADER_SOURCES}
PROPERTIES HEADER_FILE_ONLY TRUE
)
target_include_directories(librw PRIVATE "${D3D11_GENERATED_DIR}")
endif()

target_include_directories(librw
INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
Expand Down Expand Up @@ -205,6 +253,14 @@ elseif(LIBRW_PLATFORM_D3D9)
d3d9
xinput
)
elseif(LIBRW_PLATFORM_D3D11)
target_link_libraries(librw
PRIVATE
d3d11
dxgi
d3dcompiler
xinput
)
endif()

if(LIBRW_INSTALL)
Expand Down Expand Up @@ -236,6 +292,7 @@ if(LIBRW_INSTALL)
d3d/rwd3d.h
d3d/rwd3d8.h
d3d/rwd3d9.h
d3d/rwd3d11.h
DESTINATION "${LIBRW_INSTALL_INCLUDEDIR}/src/d3d"
)
install(
Expand Down
2 changes: 2 additions & 0 deletions src/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ int32 build = 0xFFFF;
int32 platform = PLATFORM_WDGL;
#elif RW_GL3
int32 platform = PLATFORM_GL3;
#elif RW_D3D11
int32 platform = PLATFORM_D3D11;
#elif RW_D3D9
int32 platform = PLATFORM_D3D9;
#else
Expand Down
Loading