Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
0404217d
Commit
0404217d
authored
May 25, 2015
by
Steve Lhomme
Committed by
Jean-Baptiste Kempf
May 26, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
direct3d11: fix picture quality when resizing
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
0b2dc749
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
113 additions
and
57 deletions
+113
-57
modules/video_output/msw/direct3d11.c
modules/video_output/msw/direct3d11.c
+113
-57
No files found.
modules/video_output/msw/direct3d11.c
View file @
0404217d
...
@@ -115,6 +115,9 @@ typedef struct d3d_vertex_t {
...
@@ -115,6 +115,9 @@ typedef struct d3d_vertex_t {
D3DXVECTOR2
texture
;
D3DXVECTOR2
texture
;
}
d3d_vertex_t
;
}
d3d_vertex_t
;
#define RECTWidth(r) (int)(r.right - r.left)
#define RECTHeight(r) (int)(r.bottom - r.top)
static
int
Open
(
vlc_object_t
*
);
static
int
Open
(
vlc_object_t
*
);
static
void
Close
(
vlc_object_t
*
object
);
static
void
Close
(
vlc_object_t
*
object
);
...
@@ -137,6 +140,8 @@ static int AllocQuad(vout_display_t *, const video_format_t *, d3d_quad_t *,
...
@@ -137,6 +140,8 @@ static int AllocQuad(vout_display_t *, const video_format_t *, d3d_quad_t *,
const
float
vertices
[
4
*
sizeof
(
d3d_vertex_t
)]);
const
float
vertices
[
4
*
sizeof
(
d3d_vertex_t
)]);
static
void
ReleaseQuad
(
d3d_quad_t
*
);
static
void
ReleaseQuad
(
d3d_quad_t
*
);
static
void
Manage
(
vout_display_t
*
vd
);
/* All the #if USE_DXGI contain an alternative method to setup dx11
/* All the #if USE_DXGI contain an alternative method to setup dx11
They both need to be benchmarked to see which performs better */
They both need to be benchmarked to see which performs better */
#if USE_DXGI
#if USE_DXGI
...
@@ -446,7 +451,7 @@ static int Open(vlc_object_t *object)
...
@@ -446,7 +451,7 @@ static int Open(vlc_object_t *object)
vd
->
prepare
=
Prepare
;
vd
->
prepare
=
Prepare
;
vd
->
display
=
Display
;
vd
->
display
=
Display
;
vd
->
control
=
CommonControl
;
vd
->
control
=
CommonControl
;
vd
->
manage
=
Common
Manage
;
vd
->
manage
=
Manage
;
msg_Dbg
(
vd
,
"Direct3D11 Open Succeeded"
);
msg_Dbg
(
vd
,
"Direct3D11 Open Succeeded"
);
...
@@ -469,6 +474,106 @@ static void Close(vlc_object_t *object)
...
@@ -469,6 +474,106 @@ static void Close(vlc_object_t *object)
free
(
vd
->
sys
);
free
(
vd
->
sys
);
}
}
static
HRESULT
UpdateBackBuffer
(
vout_display_t
*
vd
)
{
vout_display_sys_t
*
sys
=
vd
->
sys
;
HRESULT
hr
;
ID3D11Texture2D
*
pDepthStencil
;
ID3D11Texture2D
*
pBackBuffer
;
if
(
sys
->
d3drenderTargetView
)
{
ID3D11RenderTargetView_Release
(
sys
->
d3drenderTargetView
);
sys
->
d3drenderTargetView
=
NULL
;
}
if
(
sys
->
d3ddepthStencilView
)
{
ID3D11DepthStencilView_Release
(
sys
->
d3ddepthStencilView
);
sys
->
d3ddepthStencilView
=
NULL
;
}
hr
=
IDXGISwapChain_ResizeBuffers
(
sys
->
dxgiswapChain
,
1
,
RECTWidth
(
sys
->
rect_dest_clipped
),
RECTHeight
(
sys
->
rect_dest_clipped
),
DXGI_FORMAT_R8G8B8A8_UNORM
,
0
);
if
(
FAILED
(
hr
))
{
msg_Err
(
vd
,
"Failed to resize the backbuffer. (hr=0x%lX)"
,
hr
);
return
hr
;
}
hr
=
IDXGISwapChain_GetBuffer
(
sys
->
dxgiswapChain
,
0
,
&
IID_ID3D11Texture2D
,
(
LPVOID
*
)
&
pBackBuffer
);
if
(
FAILED
(
hr
))
{
msg_Err
(
vd
,
"Could not get the backbuffer for the Swapchain. (hr=0x%lX)"
,
hr
);
return
hr
;
}
hr
=
ID3D11Device_CreateRenderTargetView
(
sys
->
d3ddevice
,
(
ID3D11Resource
*
)
pBackBuffer
,
NULL
,
&
sys
->
d3drenderTargetView
);
ID3D11Texture2D_Release
(
pBackBuffer
);
D3D11_TEXTURE2D_DESC
deptTexDesc
;
memset
(
&
deptTexDesc
,
0
,
sizeof
(
deptTexDesc
));
deptTexDesc
.
ArraySize
=
1
;
deptTexDesc
.
BindFlags
=
D3D11_BIND_DEPTH_STENCIL
;
deptTexDesc
.
CPUAccessFlags
=
0
;
deptTexDesc
.
Format
=
DXGI_FORMAT_D24_UNORM_S8_UINT
;
deptTexDesc
.
Width
=
RECTWidth
(
sys
->
rect_dest_clipped
);
deptTexDesc
.
Height
=
RECTHeight
(
sys
->
rect_dest_clipped
);
deptTexDesc
.
MipLevels
=
1
;
deptTexDesc
.
MiscFlags
=
0
;
deptTexDesc
.
SampleDesc
.
Count
=
1
;
deptTexDesc
.
SampleDesc
.
Quality
=
0
;
deptTexDesc
.
Usage
=
D3D11_USAGE_DEFAULT
;
hr
=
ID3D11Device_CreateTexture2D
(
sys
->
d3ddevice
,
&
deptTexDesc
,
NULL
,
&
pDepthStencil
);
if
(
FAILED
(
hr
))
{
msg_Err
(
vd
,
"Could not create the depth stencil texture. (hr=0x%lX)"
,
hr
);
return
hr
;
}
D3D11_DEPTH_STENCIL_VIEW_DESC
depthViewDesc
;
memset
(
&
depthViewDesc
,
0
,
sizeof
(
depthViewDesc
));
depthViewDesc
.
Format
=
deptTexDesc
.
Format
;
depthViewDesc
.
ViewDimension
=
D3D11_DSV_DIMENSION_TEXTURE2D
;
depthViewDesc
.
Texture2D
.
MipSlice
=
0
;
hr
=
ID3D11Device_CreateDepthStencilView
(
sys
->
d3ddevice
,
(
ID3D11Resource
*
)
pDepthStencil
,
&
depthViewDesc
,
&
sys
->
d3ddepthStencilView
);
ID3D11Texture2D_Release
(
pDepthStencil
);
if
(
FAILED
(
hr
))
{
msg_Err
(
vd
,
"Could not create the depth stencil view. (hr=0x%lX)"
,
hr
);
return
hr
;
}
ID3D11DeviceContext_OMSetRenderTargets
(
sys
->
d3dcontext
,
1
,
&
sys
->
d3drenderTargetView
,
sys
->
d3ddepthStencilView
);
D3D11_VIEWPORT
vp
;
vp
.
Width
=
(
FLOAT
)
RECTWidth
(
sys
->
rect_dest_clipped
);
vp
.
Height
=
(
FLOAT
)
RECTHeight
(
sys
->
rect_dest_clipped
);
vp
.
MinDepth
=
0
.
0
f
;
vp
.
MaxDepth
=
1
.
0
f
;
vp
.
TopLeftX
=
0
;
vp
.
TopLeftY
=
0
;
ID3D11DeviceContext_RSSetViewports
(
sys
->
d3dcontext
,
1
,
&
vp
);
return
S_OK
;
}
static
void
Manage
(
vout_display_t
*
vd
)
{
vout_display_sys_t
*
sys
=
vd
->
sys
;
RECT
size_before
=
sys
->
rect_dest_clipped
;
CommonManage
(
vd
);
if
(
RECTWidth
(
size_before
)
!=
RECTWidth
(
sys
->
rect_dest_clipped
)
||
RECTHeight
(
size_before
)
!=
RECTHeight
(
sys
->
rect_dest_clipped
))
{
msg_Dbg
(
vd
,
"Manage detected size change %dx%d"
,
RECTWidth
(
sys
->
rect_dest_clipped
),
RECTHeight
(
sys
->
rect_dest_clipped
));
UpdateBackBuffer
(
vd
);
}
}
static
void
Prepare
(
vout_display_t
*
vd
,
picture_t
*
picture
,
subpicture_t
*
subpicture
)
static
void
Prepare
(
vout_display_t
*
vd
,
picture_t
*
picture
,
subpicture_t
*
subpicture
)
{
{
vout_display_sys_t
*
sys
=
vd
->
sys
;
vout_display_sys_t
*
sys
=
vd
->
sys
;
...
@@ -827,65 +932,16 @@ static void Direct3D11Close(vout_display_t *vd)
...
@@ -827,65 +932,16 @@ static void Direct3D11Close(vout_display_t *vd)
static
int
Direct3D11CreateResources
(
vout_display_t
*
vd
,
video_format_t
*
fmt
)
static
int
Direct3D11CreateResources
(
vout_display_t
*
vd
,
video_format_t
*
fmt
)
{
{
vout_display_sys_t
*
sys
=
vd
->
sys
;
vout_display_sys_t
*
sys
=
vd
->
sys
;
ID3D11Texture2D
*
pBackBuffer
=
NULL
;
ID3D11Texture2D
*
pDepthStencil
=
NULL
;
HRESULT
hr
;
HRESULT
hr
;
fmt
->
i_chroma
=
sys
->
vlcFormat
;
fmt
->
i_chroma
=
sys
->
vlcFormat
;
hr
=
IDXGISwapChain_GetBuffer
(
sys
->
dxgiswapChain
,
0
,
&
IID_ID3D11Texture2D
,
(
LPVOID
*
)
&
pBackBuffer
);
hr
=
UpdateBackBuffer
(
vd
);
if
(
FAILED
(
hr
))
{
msg_Err
(
vd
,
"Could not get the backbuffer from the Swapchain. (hr=0x%lX)"
,
hr
);
return
VLC_EGENERIC
;
}
hr
=
ID3D11Device_CreateRenderTargetView
(
sys
->
d3ddevice
,
(
ID3D11Resource
*
)
pBackBuffer
,
NULL
,
&
sys
->
d3drenderTargetView
);
ID3D11Texture2D_Release
(
pBackBuffer
);
if
(
FAILED
(
hr
))
{
if
(
FAILED
(
hr
))
{
msg_Err
(
vd
,
"Could not
create the render view target
. (hr=0x%lX)"
,
hr
);
msg_Err
(
vd
,
"Could not
update the backbuffer
. (hr=0x%lX)"
,
hr
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
D3D11_TEXTURE2D_DESC
deptTexDesc
;
memset
(
&
deptTexDesc
,
0
,
sizeof
(
deptTexDesc
));
deptTexDesc
.
ArraySize
=
1
;
deptTexDesc
.
BindFlags
=
D3D11_BIND_DEPTH_STENCIL
;
deptTexDesc
.
CPUAccessFlags
=
0
;
deptTexDesc
.
Format
=
DXGI_FORMAT_D24_UNORM_S8_UINT
;
deptTexDesc
.
Width
=
fmt
->
i_visible_width
;
deptTexDesc
.
Height
=
fmt
->
i_visible_height
;
deptTexDesc
.
MipLevels
=
1
;
deptTexDesc
.
MiscFlags
=
0
;
deptTexDesc
.
SampleDesc
.
Count
=
1
;
deptTexDesc
.
SampleDesc
.
Quality
=
0
;
deptTexDesc
.
Usage
=
D3D11_USAGE_DEFAULT
;
hr
=
ID3D11Device_CreateTexture2D
(
sys
->
d3ddevice
,
&
deptTexDesc
,
NULL
,
&
pDepthStencil
);
if
(
FAILED
(
hr
))
{
msg_Err
(
vd
,
"Could not create the depth stencil texture. (hr=0x%lX)"
,
hr
);
return
VLC_EGENERIC
;
}
D3D11_DEPTH_STENCIL_VIEW_DESC
depthViewDesc
;
memset
(
&
depthViewDesc
,
0
,
sizeof
(
depthViewDesc
));
depthViewDesc
.
Format
=
deptTexDesc
.
Format
;
depthViewDesc
.
ViewDimension
=
D3D11_DSV_DIMENSION_TEXTURE2D
;
depthViewDesc
.
Texture2D
.
MipSlice
=
0
;
hr
=
ID3D11Device_CreateDepthStencilView
(
sys
->
d3ddevice
,
(
ID3D11Resource
*
)
pDepthStencil
,
&
depthViewDesc
,
&
sys
->
d3ddepthStencilView
);
ID3D11Texture2D_Release
(
pDepthStencil
);
if
(
FAILED
(
hr
))
{
msg_Err
(
vd
,
"Could not create the depth stencil view. (hr=0x%lX)"
,
hr
);
return
VLC_EGENERIC
;
}
ID3D11DeviceContext_OMSetRenderTargets
(
sys
->
d3dcontext
,
1
,
&
sys
->
d3drenderTargetView
,
sys
->
d3ddepthStencilView
);
D3D11_VIEWPORT
vp
;
D3D11_VIEWPORT
vp
;
vp
.
Width
=
(
FLOAT
)
fmt
->
i_visible_width
;
vp
.
Width
=
(
FLOAT
)
fmt
->
i_visible_width
;
...
@@ -1006,11 +1062,11 @@ static int Direct3D11CreateResources(vout_display_t *vd, video_format_t *fmt)
...
@@ -1006,11 +1062,11 @@ static int Direct3D11CreateResources(vout_display_t *vd, video_format_t *fmt)
D3D11_SAMPLER_DESC
sampDesc
;
D3D11_SAMPLER_DESC
sampDesc
;
memset
(
&
sampDesc
,
0
,
sizeof
(
sampDesc
));
memset
(
&
sampDesc
,
0
,
sizeof
(
sampDesc
));
sampDesc
.
Filter
=
D3D11_FILTER_MIN_MAG_MIP_POINT
;
sampDesc
.
Filter
=
D3D11_FILTER_MIN_MAG_
LINEAR_
MIP_POINT
;
sampDesc
.
AddressU
=
D3D11_TEXTURE_ADDRESS_
CLAM
P
;
sampDesc
.
AddressU
=
D3D11_TEXTURE_ADDRESS_
WRA
P
;
sampDesc
.
AddressV
=
D3D11_TEXTURE_ADDRESS_
CLAM
P
;
sampDesc
.
AddressV
=
D3D11_TEXTURE_ADDRESS_
WRA
P
;
sampDesc
.
AddressW
=
D3D11_TEXTURE_ADDRESS_
CLAM
P
;
sampDesc
.
AddressW
=
D3D11_TEXTURE_ADDRESS_
WRA
P
;
sampDesc
.
ComparisonFunc
=
D3D11_COMPARISON_
NEVER
;
sampDesc
.
ComparisonFunc
=
D3D11_COMPARISON_
ALWAYS
;
sampDesc
.
MinLOD
=
0
;
sampDesc
.
MinLOD
=
0
;
sampDesc
.
MaxLOD
=
D3D11_FLOAT32_MAX
;
sampDesc
.
MaxLOD
=
D3D11_FLOAT32_MAX
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment