summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@mplayer2.org>2011-11-04 08:39:20 +0100
committerwm4 <wm4@mplayer2.org>2012-03-17 21:05:39 +0100
commit6f02fb1cce94e42f4b2dc39aa508ff2f5c3e519a (patch)
tree6c68c0eacd6211f417e051f92d81d74c371fe9d6
parent5ee7797bf840c2ad4a4e0a864ac65a46a55978ed (diff)
downloadmpv-6f02fb1cce94e42f4b2dc39aa508ff2f5c3e519a.tar.bz2
mpv-6f02fb1cce94e42f4b2dc39aa508ff2f5c3e519a.tar.xz
vo_direct3d: disable using shaders by default, and add direct3d_shaders VO
Now using the "direct3d" VO will never make use of shaders. Instead, users are supposed to use the direct3d_shaders VO entry, which is exactly the same as direct3d, except with shaders enabled by default. "direct3d" always uses the Direct3D StretcRect API call to render videos. Playing formats not supported by this function will force mplayer to insert a scale filter to convert video frames in software. "direct3d_shaders" prefers shader color conversion, but can fall back to StretchRect if the format can be handled. (This happens only with some insignificant packed YUV formats.)
-rw-r--r--libvo/video_out.c2
-rw-r--r--libvo/vo_direct3d.c52
2 files changed, 44 insertions, 10 deletions
diff --git a/libvo/video_out.c b/libvo/video_out.c
index 95ab8977dd..f821723242 100644
--- a/libvo/video_out.c
+++ b/libvo/video_out.c
@@ -102,6 +102,7 @@ extern struct vo_driver video_out_caca;
extern struct vo_driver video_out_mpegpes;
extern struct vo_driver video_out_yuv4mpeg;
extern struct vo_driver video_out_direct3d;
+extern struct vo_driver video_out_direct3d_shaders;
extern struct vo_driver video_out_directx;
extern struct vo_driver video_out_kva;
extern struct vo_driver video_out_dxr3;
@@ -130,6 +131,7 @@ const struct vo_driver *video_out_drivers[] =
#endif
#ifdef CONFIG_DIRECT3D
&video_out_direct3d,
+ &video_out_direct3d_shaders,
#endif
#ifdef CONFIG_DIRECTX
&video_out_directx,
diff --git a/libvo/vo_direct3d.c b/libvo/vo_direct3d.c
index c7529dadd0..619fa09fdc 100644
--- a/libvo/vo_direct3d.c
+++ b/libvo/vo_direct3d.c
@@ -49,13 +49,6 @@
// shaders generated by fxc.exe from d3d_shader_yuv.hlsl
#include "d3d_shader_yuv.h"
-static const vo_info_t info =
-{
- "Direct3D 9 Renderer",
- "direct3d",
- "Georgi Petrov (gogothebee) <gogothebee@gmail.com> and others",
- ""
-};
// TODO: beg someone to add this (there is already IMGFMT_Y8)
// equals MAKEFOURCC('Y', '1', '6', ' ')
@@ -1278,7 +1271,7 @@ const char *options_help_text = "-vo direct3d command line help:\n"
* @return 0 on success, -1 on failure
*/
-static int preinit(struct vo *vo, const char *arg)
+static int preinit_internal(struct vo *vo, const char *arg, bool allow_shaders)
{
D3DDISPLAYMODE disp_mode;
D3DCAPS9 disp_caps;
@@ -1295,6 +1288,10 @@ static int preinit(struct vo *vo, const char *arg)
.video_eq = { MP_CSP_EQ_CAPS_COLORMATRIX },
};
+ if (!allow_shaders) {
+ priv->opt_disable_shaders = priv->opt_disable_textures = true;
+ }
+
int opt_force_power_of_2 = false;
const opt_t subopts[] = {
@@ -1402,6 +1399,16 @@ err_out:
return -1;
}
+static int preinit_standard(struct vo *vo, const char *arg)
+{
+ return preinit_internal(vo, arg, false);
+}
+
+static int preinit_shaders(struct vo *vo, const char *arg)
+{
+ return preinit_internal(vo, arg, true);
+}
+
/** @brief libvo Callback: Handle control requests.
* @return VO_TRUE on success, VO_NOTIMPL when not implemented
*/
@@ -1957,10 +1964,35 @@ static void draw_eosd(d3d_priv *priv)
D3DRS_ALPHABLENDENABLE, FALSE);
}
+#define AUTHOR "Georgi Petrov (gogothebee) <gogothebee@gmail.com> and others"
+
const struct vo_driver video_out_direct3d = {
.is_new = true,
- .info = &info,
- .preinit = preinit,
+ .info = &(const vo_info_t) {
+ "Direct3D 9 Renderer",
+ "direct3d",
+ AUTHOR,
+ ""
+ },
+ .preinit = preinit_standard,
+ .config = config,
+ .control = control,
+ .draw_slice = draw_slice,
+ .draw_osd = draw_osd,
+ .flip_page = flip_page,
+ .check_events = check_events,
+ .uninit = uninit,
+};
+
+const struct vo_driver video_out_direct3d_shaders = {
+ .is_new = true,
+ .info = &(const vo_info_t) {
+ "Direct3D 9 Renderer (using shaders for YUV conversion)",
+ "direct3d_shaders",
+ AUTHOR,
+ ""
+ },
+ .preinit = preinit_shaders,
.config = config,
.control = control,
.draw_slice = draw_slice,