[vlc-commits] direct3d9: more code reordering
Steve Lhomme
git at videolan.org
Thu Jun 13 15:09:58 CEST 2019
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Jun 12 14:18:47 2019 +0200| [75f140ffcd156b83949b00669519dba7647a4a01] | committer: Steve Lhomme
direct3d9: more code reordering
Plus some comments
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=75f140ffcd156b83949b00669519dba7647a4a01
---
modules/video_output/win32/direct3d9.c | 94 +++++++++++++++++-----------------
1 file changed, 48 insertions(+), 46 deletions(-)
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index cd10d7199f..e34b5416c2 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -160,8 +160,8 @@ struct vout_display_sys_t
IDirect3DTexture9 *sceneTexture;
IDirect3DVertexBuffer9 *sceneVertexBuffer;
D3DFORMAT d3dregion_format; /* Backbuffer output format */
- size_t d3dregion_count;
- struct d3d_region_t *d3dregion;
+ size_t d3dregion_count; /* for subpictures */
+ struct d3d_region_t *d3dregion; /* for subpictures */
const d3d9_format_t *sw_texture_fmt; /* Rendering texture(s) format */
IDirect3DSurface9 *dx_render;
@@ -191,9 +191,9 @@ typedef struct
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW|D3DFVF_TEX1)
typedef struct d3d_region_t {
- D3DFORMAT format;
- unsigned width;
- unsigned height;
+ D3DFORMAT format; // for subpictures
+ unsigned width; // for pixel shaders
+ unsigned height; // for pixel shaders
CUSTOMVERTEX vertex[4];
IDirect3DTexture9 *texture;
} d3d_region_t;
@@ -445,14 +445,6 @@ static int Direct3D9ImportPicture(vout_display_t *vd,
return VLC_EGENERIC;
}
- /* retrieve texture top-level surface */
- IDirect3DSurface9 *destination;
- hr = IDirect3DTexture9_GetSurfaceLevel(sys->sceneTexture, 0, &destination);
- if (FAILED(hr)) {
- msg_Dbg(vd, "Failed IDirect3DTexture9_GetSurfaceLevel: 0x%lX", hr);
- return VLC_EGENERIC;
- }
-
/* Copy picture surface into texture surface
* color space conversion happen here */
RECT source_visible_rect = {
@@ -481,6 +473,14 @@ static int Direct3D9ImportPicture(vout_display_t *vd,
source_visible_rect.bottom++;
}
+ /* retrieve texture top-level surface */
+ IDirect3DSurface9 *destination;
+ hr = IDirect3DTexture9_GetSurfaceLevel(sys->sceneTexture, 0, &destination);
+ if (FAILED(hr)) {
+ msg_Dbg(vd, "Failed IDirect3DTexture9_GetSurfaceLevel: 0x%lX", hr);
+ return VLC_EGENERIC;
+ }
+
hr = IDirect3DDevice9_StretchRect(sys->d3d_dev.dev, source, &source_visible_rect,
destination, &texture_visible_rect,
D3DTEXF_NONE);
@@ -684,6 +684,13 @@ static int Direct3D9CreateScene(vout_display_t *vd, const video_format_t *fmt)
return VLC_EGENERIC;
}
+ // we use FVF instead of vertex shader
+ hr = IDirect3DDevice9_SetFVF(d3ddev, D3DFVF_CUSTOMVERTEX);
+ if (FAILED(hr)) {
+ msg_Dbg(vd, "Failed SetFVF: 0x%lX", hr);
+ return -1;
+ }
+
/* */
sys->d3dregion_count = 0;
sys->d3dregion = NULL;
@@ -1100,7 +1107,7 @@ static void Direct3D9ImportSubpicture(vout_display_t *vd,
}
static int Direct3D9RenderRegion(vout_display_t *vd,
- d3d_region_t *region,
+ const d3d_region_t *region,
bool use_pixel_shader)
{
vout_display_sys_t *sys = vd->sys;
@@ -1123,6 +1130,13 @@ static int Direct3D9RenderRegion(vout_display_t *vd,
return -1;
}
+ // Render the vertex buffer contents
+ hr = IDirect3DDevice9_SetStreamSource(d3ddev, 0, sys->sceneVertexBuffer, 0, sizeof(CUSTOMVERTEX));
+ if (FAILED(hr)) {
+ msg_Dbg(vd, "Failed SetStreamSource: 0x%lX", hr);
+ return -1;
+ }
+
// Setup our texture. Using textures introduces the texture stage states,
// which govern how textures get blended together (in the case of multiple
// textures) and lighting information. In this case, we are modulating
@@ -1152,20 +1166,6 @@ static int Direct3D9RenderRegion(vout_display_t *vd,
}
}
- // Render the vertex buffer contents
- hr = IDirect3DDevice9_SetStreamSource(d3ddev, 0, sys->sceneVertexBuffer, 0, sizeof(CUSTOMVERTEX));
- if (FAILED(hr)) {
- msg_Dbg(vd, "Failed SetStreamSource: 0x%lX", hr);
- return -1;
- }
-
- // we use FVF instead of vertex shader
- hr = IDirect3DDevice9_SetFVF(d3ddev, D3DFVF_CUSTOMVERTEX);
- if (FAILED(hr)) {
- msg_Dbg(vd, "Failed SetFVF: 0x%lX", hr);
- return -1;
- }
-
// draw rectangle
hr = IDirect3DDevice9_DrawPrimitive(d3ddev, D3DPT_TRIANGLEFAN, 0, 2);
if (FAILED(hr)) {
@@ -1276,15 +1276,33 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
sys->area.place_changed = false;
}
- picture_sys_d3d9_t *p_sys = picture->p_sys;
- IDirect3DSurface9 *surface = p_sys->surface;
d3d9_device_t *p_d3d9_dev = &sys->d3d_dev;
+ /* check if device is still available */
+ HRESULT hr = IDirect3DDevice9_TestCooperativeLevel(p_d3d9_dev->dev);
+ if (FAILED(hr)) {
+ if (hr == D3DERR_DEVICENOTRESET && !sys->reset_device) {
+ if (vd->info.has_pictures_invalid)
+ vout_display_SendEventPicturesInvalid(vd);
+ sys->reset_device = true;
+ sys->lost_not_ready = false;
+ }
+ if (hr == D3DERR_DEVICELOST && !sys->lost_not_ready) {
+ /* Device is lost but not yet ready for reset. */
+ sys->lost_not_ready = true;
+ }
+ return;
+ }
+
/* FIXME it is a bit ugly, we need the surface to be unlocked for
* rendering.
* The clean way would be to release the picture (and ensure that
* the vout doesn't keep a reference). But because of the vout
* wrapper, we can't */
+ IDirect3DSurface9 *surface;
+
+ picture_sys_d3d9_t *p_sys = picture->p_sys;
+ surface = p_sys->surface;
if ( !is_d3d9_opaque(picture->format.i_chroma) )
{
D3DLOCKED_RECT d3drect;
@@ -1327,22 +1345,6 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
}
}
- /* check if device is still available */
- HRESULT hr = IDirect3DDevice9_TestCooperativeLevel(p_d3d9_dev->dev);
- if (FAILED(hr)) {
- if (hr == D3DERR_DEVICENOTRESET && !sys->reset_device) {
- if (vd->info.has_pictures_invalid)
- vout_display_SendEventPicturesInvalid(vd);
- sys->reset_device = true;
- sys->lost_not_ready = false;
- }
- if (hr == D3DERR_DEVICELOST && !sys->lost_not_ready) {
- /* Device is lost but not yet ready for reset. */
- sys->lost_not_ready = true;
- }
- return;
- }
-
d3d_region_t picture_region;
if (!Direct3D9ImportPicture(vd, &picture_region, surface)) {
picture_region.width = picture->format.i_visible_width;
More information about the vlc-commits
mailing list