Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ option(ENABLE_HEVC "Enable HEVC encoders" ON)
add_subdirectory(libobs)
if(OS_WINDOWS)
add_subdirectory(libobs-d3d11)
add_subdirectory(libobs-d3d12)
add_subdirectory(libobs-winrt)
endif()
add_subdirectory(libobs-opengl)
Expand Down
7 changes: 6 additions & 1 deletion cmake/windows/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ function(set_target_properties_obs target)
elseif(target_type STREQUAL MODULE_LIBRARY)
set_target_properties(${target} PROPERTIES VERSION 0 SOVERSION ${OBS_VERSION_CANONICAL})

if(target STREQUAL libobs-d3d11 OR target STREQUAL libobs-opengl OR target STREQUAL libobs-winrt)
if(
target STREQUAL libobs-d3d11
OR target STREQUAL libobs-d3d12
OR target STREQUAL libobs-opengl
OR target STREQUAL libobs-winrt
)
set(target_destination "${OBS_EXECUTABLE_DESTINATION}")
elseif(target STREQUAL "obspython" OR target STREQUAL "obslua")
set(target_destination "${OBS_SCRIPT_PLUGIN_DESTINATION}")
Expand Down
2 changes: 1 addition & 1 deletion frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ elseif(OS_FREEBSD OR OS_OPENBSD)
include(cmake/os-freebsd.cmake)
endif()

foreach(graphics_library IN ITEMS opengl metal d3d11)
foreach(graphics_library IN ITEMS opengl metal d3d11 d3d12)
string(TOUPPER ${graphics_library} graphics_library_U)
if(TARGET OBS::libobs-${graphics_library})
target_compile_definitions(
Expand Down
10 changes: 7 additions & 3 deletions frontend/OBSApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1120,11 +1120,15 @@ const char *OBSApp::GetRenderModule() const
{
#if defined(_WIN32)
const char *renderer = config_get_string(appConfig, "Video", "Renderer");

return (astrcmpi(renderer, "Direct3D 11") == 0) ? DL_D3D11 : DL_OPENGL;
if (astrcmpi(renderer, "Direct3D 12") == 0) {
return DL_D3D12;
} else if (astrcmpi(renderer, "Direct3D 11") == 0) {
return DL_D3D11;
} else {
return DL_OPENGL;
}
#elif defined(__APPLE__) && defined(__aarch64__)
const char *renderer = config_get_string(appConfig, "Video", "Renderer");

return (astrcmpi(renderer, "Metal") == 0) ? DL_METAL : DL_OPENGL;
#else
return DL_OPENGL;
Expand Down
1 change: 1 addition & 0 deletions frontend/settings/OBSBasicSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,7 @@ void OBSBasicSettings::LoadRendererList()
const char *renderer = config_get_string(App()->GetAppConfig(), "Video", "Renderer");
#ifdef _WIN32
ui->renderer->addItem(QString("Direct3D 11"), QString("Direct3D 11"));
ui->renderer->addItem(QString("Direct3D 12"), QString("Direct3D 12"));
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Direct3D 12(Beta)?

if (opt_allow_opengl || strcmp(renderer, "OpenGL") == 0) {
ui->renderer->addItem(QString("OpenGL"), QString("OpenGL"));
}
Expand Down
2 changes: 2 additions & 0 deletions libobs-d3d11/d3d11-subsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2189,6 +2189,8 @@ void device_begin_frame(gs_device_t *device)
reset_duplicators();
}

void device_end_frame(gs_device_t *device) {}

void device_begin_scene(gs_device_t *device)
{
clear_textures(device);
Expand Down
66 changes: 66 additions & 0 deletions libobs-d3d12/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
cmake_minimum_required(VERSION 3.28...3.30)

add_library(libobs-d3d12 MODULE)
add_library(OBS::libobs-d3d12 ALIAS libobs-d3d12)

target_sources(
libobs-d3d12
PRIVATE # cmake-format: unsort
d3d12-common.cpp
d3d12-common.hpp
d3d12-linearallocator.cpp
d3d12-linearallocator.hpp
d3d12-gpubuffer.cpp
d3d12-gpubuffer.hpp
d3d12-rootsignature.cpp
d3d12-rootsignature.hpp
d3d12-descriptorallocator.cpp
d3d12-descriptorallocator.hpp
d3d12-dynamic-descriptorheap.cpp
d3d12-dynamic-descriptorheap.hpp
d3d12-commandqueue.cpp
d3d12-commandqueue.hpp
d3d12-pipeline.cpp
d3d12-pipeline.hpp
d3d12-context.cpp
d3d12-context.hpp
d3d12-deviceinstance.cpp
d3d12-deviceinstance.hpp
d3d12-duplicator.cpp
d3d12-indexbuffer.cpp
d3d12-samplerstate.cpp
d3d12-shader.cpp
d3d12-shaderprocessor.cpp
d3d12-shaderprocessor.hpp
d3d12-stagesurf.cpp
d3d12-subsystem.cpp
d3d12-subsystem.hpp
d3d12-texture2d.cpp
d3d12-texture3d.cpp
d3d12-vertexbuffer.cpp
d3d12-zstencilbuffer.cpp
)

configure_file(cmake/windows/obs-module.rc.in libobs-d3d12.rc)
target_sources(libobs-d3d12 PRIVATE libobs-d3d12.rc)

target_compile_definitions(
libobs-d3d12
PRIVATE
$<$<BOOL:${GPU_PRIORITY_VAL}>:USE_GPU_PRIORITY>
"$<IF:$<BOOL:${GPU_PRIORITY_VAL}>,GPU_PRIORITY_VAL=${GPU_PRIORITY_VAL},GPU_PRIORITY_VAL=0>"
)

target_link_libraries(
libobs-d3d12
PRIVATE OBS::libobs d3d11 d3d12 dxguid d3dcompiler dxgi shcore
)

target_enable_feature(libobs "Direct3D 12 renderer")

set_target_properties_obs(
libobs-d3d12
PROPERTIES FOLDER core
VERSION 0
SOVERSION ${OBS_VERSION_MAJOR} COMPILE_WARNING_AS_ERROR FALSE
)
24 changes: 24 additions & 0 deletions libobs-d3d12/cmake/windows/obs-module.rc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
1 VERSIONINFO
FILEVERSION ${OBS_VERSION_MAJOR},${OBS_VERSION_MINOR},${OBS_VERSION_PATCH},0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "${OBS_COMPANY_NAME}"
VALUE "FileDescription", "OBS Library D3D12 wrapper"
VALUE "FileVersion", "${OBS_VERSION_CANONICAL}"
VALUE "ProductName", "${OBS_PRODUCT_NAME}"
VALUE "ProductVersion", "${OBS_VERSION_CANONICAL}"
VALUE "Comments", "${OBS_COMMENTS}"
VALUE "LegalCopyright", "${OBS_LEGAL_COPYRIGHT}"
VALUE "InternalName", "libobs-d3d12"
VALUE "OriginalFilename", "libobs-d3d12"
END
END

BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 0x04B0
END
END
Loading
Loading