summaryrefslogtreecommitdiffstats
path: root/video/out/vo_direct3d.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-12-23 12:46:20 +0100
committerwm4 <wm4@nowhere>2013-01-13 20:04:14 +0100
commit9f27ebbe6392fa5fd14b685d9f0a20c59b3a4535 (patch)
treef292aab6c04f4866ae864c787cda14c3401be2eb /video/out/vo_direct3d.c
parentdd89c542e3364bd4f9294c3ac5bcbfb6b0f16594 (diff)
downloadmpv-9f27ebbe6392fa5fd14b685d9f0a20c59b3a4535.tar.bz2
mpv-9f27ebbe6392fa5fd14b685d9f0a20c59b3a4535.tar.xz
vo_direct3d: remove 2ch hack for 10 bit playback
This was an awkward hack that attempted to avoid the use of 16 bit textures, while still allowing rendering 10-16 bit YUV formats. The idea was that even if the hardware doesn't support 16 bit textures, an A8L8 textures could be used to convert 10 bit (etc.) to 8 bit in the shader, instead of doing this on the CPU. This was an experiment, disabled by default, and was (probably) rarely used. I've never heard of this being used successfully. Remove it.
Diffstat (limited to 'video/out/vo_direct3d.c')
-rw-r--r--video/out/vo_direct3d.c81
1 files changed, 5 insertions, 76 deletions
diff --git a/video/out/vo_direct3d.c b/video/out/vo_direct3d.c
index 6b9ca7e32b..0b9317f22e 100644
--- a/video/out/vo_direct3d.c
+++ b/video/out/vo_direct3d.c
@@ -45,13 +45,9 @@
// shaders generated by fxc.exe from d3d_shader_yuv.hlsl
#include "d3d_shader_yuv.h"
-#include "d3d_shader_yuv_2ch.h"
-// TODO: beg someone to add this (there is already IMGFMT_Y8)
-#define IMGFMT_A8Y8 MAKEFOURCC('A', '8', 'Y', '8')
-
-#define IMGFMT_IS_Y(x) ((x) == IMGFMT_Y8 || (x) == IMGFMT_Y16 || (x) == IMGFMT_A8Y8)
+#define IMGFMT_IS_Y(x) ((x) == IMGFMT_Y8 || (x) == IMGFMT_Y16)
#define IMGFMT_Y_DEPTH(x) ((x) == IMGFMT_Y8 ? 8 : 16)
#define DEVTYPE D3DDEVTYPE_HAL
@@ -130,7 +126,6 @@ typedef struct d3d_priv {
int opt_texture_memory;
int opt_swap_discard;
int opt_exact_backbuffer;
- int opt_16bit_textures;
struct vo *vo;
@@ -149,7 +144,6 @@ typedef struct d3d_priv {
StretchRect */
bool use_shaders; /**< use shader for YUV color conversion
(or possibly for RGB video equalizers) */
- bool use_2ch_hack; /**< 2 byte YUV formats use 2 channel hack */
int plane_count;
struct texplane planes[3];
@@ -185,7 +179,6 @@ typedef struct d3d_priv {
int max_texture_height; /**< from the device capabilities */
D3DMATRIX d3d_colormatrix;
- float d3d_depth_vector[4];
struct mp_csp_details colorspace;
struct mp_csp_equalizer video_eq;
@@ -219,7 +212,6 @@ static const struct fmt_entry fmt_table[] = {
// grayscale (can be considered both packed and planar)
{IMGFMT_Y8, D3DFMT_L8},
{IMGFMT_Y16, D3DFMT_L16},
- {IMGFMT_A8Y8, D3DFMT_A8L8},
{0},
};
@@ -921,9 +913,6 @@ static uint32_t d3d_draw_frame(d3d_priv *priv)
IDirect3DDevice9_SetPixelShaderConstantF(priv->d3d_device, 0,
&priv->d3d_colormatrix._11,
4);
- IDirect3DDevice9_SetPixelShaderConstantF(priv->d3d_device, 5,
- priv->d3d_depth_vector,
- 1);
}
IDirect3DDevice9_SetFVF(priv->d3d_device, D3DFVF_VIDEO_VERTEX);
@@ -1042,13 +1031,7 @@ static D3DFORMAT check_shader_conversion(d3d_priv *priv, uint32_t fmt)
bool is_8bit = component_bits == 8;
if (!is_8bit && priv->opt_only_8bit)
return 0;
- int texfmt = IMGFMT_Y8;
- if (!is_8bit) {
- if (priv->opt_16bit_textures)
- texfmt = IMGFMT_Y16;
- else
- texfmt = IMGFMT_A8Y8;
- }
+ int texfmt = is_8bit ? IMGFMT_Y8 : IMGFMT_Y16;
return check_format(priv, texfmt, true);
}
@@ -1084,7 +1067,6 @@ static bool init_rendering_mode(d3d_priv *priv, uint32_t fmt, bool initialize)
priv->use_shaders = false;
priv->use_textures = false;
- priv->use_2ch_hack = false;
priv->movie_src_fmt = 0;
priv->pixel_shader_data = NULL;
priv->plane_count = 0;
@@ -1127,14 +1109,7 @@ static bool init_rendering_mode(d3d_priv *priv, uint32_t fmt, bool initialize)
if (n > 0)
planes[n].clearval = get_chroma_clear_val(desc.plane_bits);
}
- if (shader_d3dfmt != D3DFMT_A8L8) {
- priv->pixel_shader_data = d3d_shader_yuv;
- } else {
- mp_msg(MSGT_VO, MSGL_WARN, "<vo_direct3d>Using YUV 2ch hack.\n");
-
- priv->pixel_shader_data = d3d_shader_yuv_2ch;
- priv->use_2ch_hack = true;
- }
+ priv->pixel_shader_data = d3d_shader_yuv;
}
for (n = 0; n < priv->plane_count; n++) {
@@ -1178,30 +1153,6 @@ static int query_format(struct vo *vo, uint32_t movie_fmt)
* *
****************************************************************************/
-static void get_2ch_depth_multiplier(int depth, float *out_f1, float *out_f2) {
- // How to get these values:
- // The suffix i8 and i16 is for values with 8/16 bit fixed point numbers.
- // The suffix f is for float, ideally in the range 0.0-1.0.
- // c_i8 is a two component vector, sampled from a two channel texture.
- // (c_i8.x is the low byte, c_i8.y is the high byte)
- // r_f is the resulting color scalar value.
- //
- // c_i8 = c_f * (2^8-1)
- // r_i16 = c_i8.x + c_i8.y * 2^8
- // r_f = r_i16 / (2^16-1)
- // = c_f.x * (2^8-1) / (2^16-1) + c_f.y * (2^8-1) * 2^8 / (2^16-1)
- // = c_f.x * ((2^8-1) / (2^16-1)) + c_f.y * (2^8 * ((2^8-1) / (2^16-1)))
- // out = ((2^8-1) / (2^16-1), 2^8 * ((2^8-1) / (2^16-1)))
- // The result color is r_f = dot(c_f, out).
- // Same goes for other bit depth, such as 10 bit. Assuming (2^depth-1) is
- // the maximum possible value at that depth, you have to scale the value
- // r_i16 with it, the factor (2^16-1) in the formula above has to be
- // replaced with (2^depth-1).
- float factor = (float)((1 << 8) - 1) / (float)((1 << depth) - 1);
- *out_f1 = factor;
- *out_f2 = 256.0 * factor;
-}
-
static void update_colorspace(d3d_priv *priv)
{
float coeff[3][4];
@@ -1209,19 +1160,8 @@ static void update_colorspace(d3d_priv *priv)
mp_csp_copy_equalizer_values(&csp, &priv->video_eq);
if (priv->use_shaders) {
- if (!priv->use_2ch_hack) {
- csp.input_bits = priv->planes[0].bits_per_pixel;
- csp.texture_bits = (csp.input_bits + 7) & ~7;
- } else {
- float f1, f2;
- get_2ch_depth_multiplier(priv->planes[0].bits_per_pixel, &f1, &f2);
- priv->d3d_depth_vector[0] = f1;
- priv->d3d_depth_vector[1] = f2;
- priv->d3d_depth_vector[2] = priv->d3d_depth_vector[3] = 0;
- // no change
- csp.input_bits = 8;
- csp.texture_bits = 8;
- }
+ csp.input_bits = priv->planes[0].bits_per_pixel;
+ csp.texture_bits = (csp.input_bits + 7) & ~7;
mp_get_yuv2rgb_coeffs(&csp, coeff);
for (int row = 0; row < 3; row++) {
@@ -1274,14 +1214,6 @@ const char *options_help_text = "-vo direct3d command line help:\n"
" Might be slower too, as it must (?) clear every frame.\n"
" exact-backbuffer\n"
" Always resize the backbuffer to window size.\n"
-" no16bit-textures\n"
-" Don't use textures with a 16 bit color channel for YUV formats that\n"
-" use more than 8 bits per component. Instead, use D3DFMT_A8L8 textures\n"
-" and compute the values sampled from the 2 channels back into one.\n"
-" Might be slower, since the shader becomes slightly more complicated.\n"
-" Might work better, if your drivers either don't support D3DFMT_L16,\n"
-" or if either the texture unit or the shaders don't operate in at least\n"
-" 16 bit precision.\n"
"";
/** @brief libvo Callback: Preinitialize the video card.
@@ -1299,8 +1231,6 @@ static int preinit_internal(struct vo *vo, const char *arg, bool allow_shaders)
*priv = (d3d_priv) {
.vo = vo,
- .opt_16bit_textures = true,
-
.colorspace = MP_CSP_DETAILS_DEFAULTS,
.video_eq = { MP_CSP_EQ_CAPS_COLORMATRIX },
};
@@ -1329,7 +1259,6 @@ static int preinit_internal(struct vo *vo, const char *arg, bool allow_shaders)
{"texture-memory", OPT_ARG_INT, &priv->opt_texture_memory},
{"swap-discard", OPT_ARG_BOOL, &priv->opt_swap_discard},
{"exact-backbuffer", OPT_ARG_BOOL, &priv->opt_exact_backbuffer},
- {"16bit-textures", OPT_ARG_BOOL, &priv->opt_16bit_textures},
{NULL}
};
if (subopt_parse(arg, subopts) != 0) {