Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小白菜888
Obs Studio
提交
2d547cf6
O
Obs Studio
项目概览
小白菜888
/
Obs Studio
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Obs Studio
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2d547cf6
编写于
11月 22, 2020
作者:
J
jpark37
提交者:
Jim
11月 24, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libobs: Allow wrapping D3D11 object with gs_texture_t
This can be useful for reading from textures provided by middleware.
上级
f0593f38
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
62 addition
and
0 deletion
+62
-0
libobs-d3d11/d3d11-subsystem.cpp
libobs-d3d11/d3d11-subsystem.cpp
+17
-0
libobs-d3d11/d3d11-subsystem.hpp
libobs-d3d11/d3d11-subsystem.hpp
+1
-0
libobs-d3d11/d3d11-texture2d.cpp
libobs-d3d11/d3d11-texture2d.cpp
+27
-0
libobs/graphics/graphics-imports.c
libobs/graphics/graphics-imports.c
+1
-0
libobs/graphics/graphics-internal.h
libobs/graphics/graphics-internal.h
+2
-0
libobs/graphics/graphics.c
libobs/graphics/graphics.c
+12
-0
libobs/graphics/graphics.h
libobs/graphics/graphics.h
+2
-0
未找到文件。
libobs-d3d11/d3d11-subsystem.cpp
浏览文件 @
2d547cf6
...
...
@@ -2670,6 +2670,23 @@ extern "C" EXPORT uint32_t device_texture_get_shared_handle(gs_texture_t *tex)
return
tex2d
->
isShared
?
tex2d
->
sharedHandle
:
GS_INVALID_HANDLE
;
}
extern
"C"
EXPORT
gs_texture_t
*
device_texture_wrap_obj
(
gs_device_t
*
device
,
void
*
obj
)
{
gs_texture
*
texture
=
nullptr
;
try
{
texture
=
new
gs_texture_2d
(
device
,
(
ID3D11Texture2D
*
)
obj
);
}
catch
(
const
HRError
&
error
)
{
blog
(
LOG_ERROR
,
"gs_texture_wrap_obj (D3D11): %s (%08lX)"
,
error
.
str
,
error
.
hr
);
LogD3D11ErrorDetails
(
error
,
device
);
}
catch
(
const
char
*
error
)
{
blog
(
LOG_ERROR
,
"gs_texture_wrap_obj (D3D11): %s"
,
error
);
}
return
texture
;
}
int
device_texture_acquire_sync
(
gs_texture_t
*
tex
,
uint64_t
key
,
uint32_t
ms
)
{
gs_texture_2d
*
tex2d
=
reinterpret_cast
<
gs_texture_2d
*>
(
tex
);
...
...
libobs-d3d11/d3d11-subsystem.hpp
浏览文件 @
2d547cf6
...
...
@@ -490,6 +490,7 @@ struct gs_texture_2d : gs_texture {
gs_texture_2d
(
gs_device_t
*
device
,
ID3D11Texture2D
*
nv12
,
uint32_t
flags
);
gs_texture_2d
(
gs_device_t
*
device
,
uint32_t
handle
);
gs_texture_2d
(
gs_device_t
*
device
,
ID3D11Texture2D
*
obj
);
};
struct
gs_texture_3d
:
gs_texture
{
...
...
libobs-d3d11/d3d11-texture2d.cpp
浏览文件 @
2d547cf6
...
...
@@ -311,3 +311,30 @@ gs_texture_2d::gs_texture_2d(gs_device_t *device, uint32_t handle)
if
(
FAILED
(
hr
))
throw
HRError
(
"Failed to create shader resource view"
,
hr
);
}
gs_texture_2d
::
gs_texture_2d
(
gs_device_t
*
device
,
ID3D11Texture2D
*
obj
)
:
gs_texture
(
device
,
gs_type
::
gs_texture_2d
,
GS_TEXTURE_2D
)
{
texture
=
obj
;
texture
->
GetDesc
(
&
td
);
this
->
type
=
GS_TEXTURE_2D
;
this
->
format
=
ConvertDXGITextureFormat
(
td
.
Format
);
this
->
levels
=
1
;
this
->
device
=
device
;
this
->
width
=
td
.
Width
;
this
->
height
=
td
.
Height
;
this
->
dxgiFormat
=
td
.
Format
;
memset
(
&
resourceDesc
,
0
,
sizeof
(
resourceDesc
));
resourceDesc
.
Format
=
td
.
Format
;
resourceDesc
.
ViewDimension
=
D3D11_SRV_DIMENSION_TEXTURE2D
;
resourceDesc
.
Texture2D
.
MipLevels
=
1
;
HRESULT
hr
=
device
->
device
->
CreateShaderResourceView
(
texture
,
&
resourceDesc
,
shaderRes
.
Assign
());
if
(
FAILED
(
hr
))
throw
HRError
(
"Failed to create shader resource view"
,
hr
);
}
libobs/graphics/graphics-imports.c
浏览文件 @
2d547cf6
...
...
@@ -210,6 +210,7 @@ bool load_graphics_imports(struct gs_exports *exports, void *module,
GRAPHICS_IMPORT_OPTIONAL
(
gs_texture_release_dc
);
GRAPHICS_IMPORT_OPTIONAL
(
device_texture_open_shared
);
GRAPHICS_IMPORT_OPTIONAL
(
device_texture_get_shared_handle
);
GRAPHICS_IMPORT_OPTIONAL
(
device_texture_wrap_obj
);
GRAPHICS_IMPORT_OPTIONAL
(
device_texture_acquire_sync
);
GRAPHICS_IMPORT_OPTIONAL
(
device_texture_release_sync
);
GRAPHICS_IMPORT_OPTIONAL
(
device_texture_create_nv12
);
...
...
libobs/graphics/graphics-internal.h
浏览文件 @
2d547cf6
...
...
@@ -299,6 +299,8 @@ struct gs_exports {
gs_texture_t
*
(
*
device_texture_open_shared
)(
gs_device_t
*
device
,
uint32_t
handle
);
uint32_t
(
*
device_texture_get_shared_handle
)(
gs_texture_t
*
tex
);
gs_texture_t
*
(
*
device_texture_wrap_obj
)(
gs_device_t
*
device
,
void
*
obj
);
int
(
*
device_texture_acquire_sync
)(
gs_texture_t
*
tex
,
uint64_t
key
,
uint32_t
ms
);
int
(
*
device_texture_release_sync
)(
gs_texture_t
*
tex
,
uint64_t
key
);
...
...
libobs/graphics/graphics.c
浏览文件 @
2d547cf6
...
...
@@ -2885,6 +2885,18 @@ uint32_t gs_texture_get_shared_handle(gs_texture_t *tex)
return
GS_INVALID_HANDLE
;
}
gs_texture_t
*
gs_texture_wrap_obj
(
void
*
obj
)
{
graphics_t
*
graphics
=
thread_graphics
;
if
(
!
gs_valid
(
"gs_texture_wrap_obj"
))
return
NULL
;
if
(
graphics
->
exports
.
device_texture_wrap_obj
)
return
graphics
->
exports
.
device_texture_wrap_obj
(
graphics
->
device
,
obj
);
return
NULL
;
}
int
gs_texture_acquire_sync
(
gs_texture_t
*
tex
,
uint64_t
key
,
uint32_t
ms
)
{
graphics_t
*
graphics
=
thread_graphics
;
...
...
libobs/graphics/graphics.h
浏览文件 @
2d547cf6
...
...
@@ -867,6 +867,8 @@ EXPORT gs_texture_t *gs_texture_open_shared(uint32_t handle);
#define GS_INVALID_HANDLE (uint32_t) - 1
EXPORT
uint32_t
gs_texture_get_shared_handle
(
gs_texture_t
*
tex
);
EXPORT
gs_texture_t
*
gs_texture_wrap_obj
(
void
*
obj
);
#define GS_WAIT_INFINITE (uint32_t) - 1
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录