Render: Add global alpha support for subpicture
authorLi,Xiaowei <xiaowei.a.li@intel.com>
Fri, 23 Nov 2012 03:13:48 +0000 (11:13 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Fri, 14 Dec 2012 02:50:23 +0000 (10:50 +0800)
Signed-off-by: Li Xiaowei A <xiaowei.a.li@intel.com>
17 files changed:
src/i965_drv_video.c
src/i965_drv_video.h
src/i965_render.c
src/shaders/render/exa_wm_src_sample_argb.g4a
src/shaders/render/exa_wm_src_sample_argb.g4b
src/shaders/render/exa_wm_src_sample_argb.g4b.gen5
src/shaders/render/exa_wm_src_sample_argb.g6a
src/shaders/render/exa_wm_src_sample_argb.g6b
src/shaders/render/exa_wm_src_sample_argb.g7a
src/shaders/render/exa_wm_src_sample_argb.g7b
src/shaders/render/exa_wm_yuv_rgb.g4a
src/shaders/render/exa_wm_yuv_rgb.g4b
src/shaders/render/exa_wm_yuv_rgb.g4b.gen5
src/shaders/render/exa_wm_yuv_rgb.g6a
src/shaders/render/exa_wm_yuv_rgb.g6b
src/shaders/render/exa_wm_yuv_rgb.g7a
src/shaders/render/exa_wm_yuv_rgb.g7b

index 37707e8..ddbd420 100755 (executable)
@@ -867,6 +867,8 @@ i965_CreateSubpicture(VADriverContextP ctx,
     obj_subpic->height = obj_image->image.height;
     obj_subpic->pitch  = obj_image->image.pitches[0];
     obj_subpic->bo     = obj_image->bo;
+    obj_subpic->global_alpha = 1.0;
     return VA_STATUS_SUCCESS;
 }
 
@@ -905,8 +907,15 @@ i965_SetSubpictureGlobalAlpha(VADriverContextP ctx,
                               VASubpictureID subpicture,
                               float global_alpha)
 {
-    /* TODO */
-    return VA_STATUS_ERROR_UNIMPLEMENTED;
+    struct i965_driver_data *i965 = i965_driver_data(ctx);
+    struct object_subpic *obj_subpic = SUBPIC(subpicture);
+
+    if(global_alpha > 1.0 || global_alpha < 0.0){
+       return VA_STATUS_ERROR_INVALID_PARAMETER;
+    }
+    obj_subpic->global_alpha  = global_alpha;
+
+    return VA_STATUS_SUCCESS;
 }
 
 VAStatus 
index 6d10a6d..c8750da 100644 (file)
@@ -239,6 +239,7 @@ struct object_subpic
     int width;
     int height;
     int pitch;
+    float global_alpha;
     dri_bo *bo;
     unsigned int flags;
 };
index 9cade78..f43df1e 100644 (file)
@@ -1090,6 +1090,32 @@ i965_render_upload_constants(VADriverContextP ctx,
 }
 
 static void
+i965_subpic_render_upload_constants(VADriverContextP ctx,
+                             VASurfaceID surface)
+{
+    struct i965_driver_data *i965 = i965_driver_data(ctx);
+    struct i965_render_state *render_state = &i965->render_state;
+    float *constant_buffer;
+    float global_alpha = 1.0;
+    struct object_surface *obj_surface = SURFACE(surface);
+
+    if(obj_surface->subpic != VA_INVALID_ID){
+        struct object_subpic *obj_subpic= SUBPIC(obj_surface->subpic);
+        if(obj_subpic->flags & VA_SUBPICTURE_GLOBAL_ALPHA){
+           global_alpha = obj_subpic->global_alpha;
+        }
+     }   
+
+    dri_bo_map(render_state->curbe.bo, 1);
+
+    assert(render_state->curbe.bo->virtual);
+    constant_buffer = render_state->curbe.bo->virtual;
+    *constant_buffer = global_alpha;
+
+    dri_bo_unmap(render_state->curbe.bo);
+}
+static void
 i965_surface_render_state_setup(
     VADriverContextP   ctx,
     VASurfaceID        surface,
@@ -1126,6 +1152,7 @@ i965_subpic_render_state_setup(
     i965_subpic_render_wm_unit(ctx);
     i965_render_cc_viewport(ctx);
     i965_subpic_render_cc_unit(ctx);
+    i965_subpic_render_upload_constants(ctx, surface);
     i965_subpic_render_upload_vertex(ctx, surface, dst_rect);
 }
 
@@ -2194,6 +2221,7 @@ gen6_subpicture_render_setup_states(
     gen6_render_color_calc_state(ctx);
     gen6_subpicture_render_blend_state(ctx);
     gen6_render_depth_stencil_state(ctx);
+    i965_subpic_render_upload_constants(ctx, surface);
     i965_subpic_render_upload_vertex(ctx, surface, dst_rect);
 }
 
@@ -2971,6 +2999,7 @@ gen7_subpicture_render_setup_states(
     gen7_render_color_calc_state(ctx);
     gen7_subpicture_render_blend_state(ctx);
     gen7_render_depth_stencil_state(ctx);
+    i965_subpic_render_upload_constants(ctx, surface);
     i965_subpic_render_upload_vertex(ctx, surface, dst_rect);
 }
 
index c20f53f..8cc693e 100644 (file)
@@ -28,6 +28,8 @@
 /* Sample the src surface */
 
 include(`exa_wm.g4i')
+define(`global_alpha',     `r2.0<0,1,0>f')
 
 /* prepare sampler read back gX register, which would be written back to output */
 
@@ -45,3 +47,6 @@ send (16) src_msg_ind         /* msg reg index */
        sampler (1,0,F)         /* sampler message description, (binding_table,sampler_index,datatype)
                                /* here(src->dst) we should use src_sampler and src_surface */
        mlen 5 rlen 8 { align1 };   /* required message len 5, readback len 8 */
+
+mul (8) src_sample_a_01<1>f src_sample_a_01<1>f global_alpha { align1 };
+mul (8) src_sample_a_23<1>f src_sample_a_23<1>f global_alpha { align1 };
index c5b9274..963c121 100644 (file)
@@ -1,2 +1,4 @@
    { 0x00000201, 0x20080061, 0x00000000, 0x00000000 },
    { 0x01800031, 0x21c01d29, 0x008d0000, 0x02580001 },
+   { 0x00600041, 0x228077bd, 0x00200280, 0x00000040 },
+   { 0x00600041, 0x22a077bd, 0x002002a0, 0x00000040 },
index f8cb41e..45b3641 100644 (file)
@@ -1,2 +1,4 @@
    { 0x00000201, 0x20080061, 0x00000000, 0x00000000 },
    { 0x01800031, 0x21c01d29, 0x208d0000, 0x0a8a0001 },
+   { 0x00600041, 0x228077bd, 0x00200280, 0x00000040 },
+   { 0x00600041, 0x22a077bd, 0x002002a0, 0x00000040 },
index 67bb888..48e79f7 100644 (file)
@@ -29,6 +29,9 @@
 
 include(`exa_wm.g4i')
 
+/* subpicture global alpha */
+define(`global_alpha',     `r6.0<0,1,0>f')
+
 /* prepare sampler read back gX register, which would be written back to output */
 
 /* use simd16 sampler, param 0 is u, param 1 is v. */
@@ -46,3 +49,7 @@ send (16) src_msg_ind         /* msg reg index */
        sampler (1,0,F)         /* sampler message description, (binding_table,sampler_index,datatype)
                                /* here(src->dst) we should use src_sampler and src_surface */
        mlen 5 rlen 8 { align1 };   /* required message len 5, readback len 8 */
+
+mul (8) src_sample_a_01<1>f src_sample_a_01<1>f global_alpha { align1 };
+mul (8) src_sample_a_23<1>f src_sample_a_23<1>f global_alpha { align1 };
+
index 2846491..8964e45 100644 (file)
@@ -1,3 +1,5 @@
    { 0x00000201, 0x20080061, 0x00000000, 0x00000000 },
    { 0x00600201, 0x20200022, 0x008d0000, 0x00000000 },
    { 0x02800031, 0x21c01cc9, 0x00000020, 0x0a8a0001 },
+   { 0x00600041, 0x228077bd, 0x00200280, 0x000000c0 },
+   { 0x00600041, 0x22a077bd, 0x002002a0, 0x000000c0 },
index 978b76f..620e0e7 100644 (file)
@@ -33,6 +33,9 @@ include(`exa_wm.g4i')
 define(`src_msg_gen7',   `g65')
 define(`src_msg_ind_gen7',`65')
 
+/* subpicture global alpha */
+define(`global_alpha',     `r6.0<0,1,0>f')
+
 /* prepare sampler read back gX register, which would be written back to output */
 
 /* use simd16 sampler, param 0 is u, param 1 is v. */
@@ -50,3 +53,7 @@ send (16) src_msg_ind_gen7    /* msg reg index */
        sampler (1,0,F)         /* sampler message description, (binding_table,sampler_index,datatype)
                                /* here(src->dst) we should use src_sampler and src_surface */
        mlen 5 rlen 8 { align1 };   /* required message len 5, readback len 8 */
+
+mul (8) src_sample_a_01<1>f src_sample_a_01<1>f global_alpha { align1 mask_disable };
+mul (8) src_sample_a_23<1>f src_sample_a_23<1>f global_alpha { align1 mask_disable };
+
index e9b12e6..674fc74 100644 (file)
@@ -1,3 +1,5 @@
    { 0x00000201, 0x20080061, 0x00000000, 0x00000000 },
    { 0x00600201, 0x28200021, 0x008d0000, 0x00000000 },
    { 0x02800031, 0x21c01ca9, 0x00000820, 0x0a8c0001 },
+   { 0x00600241, 0x228077bd, 0x00200280, 0x000000c0 },
+   { 0x00600241, 0x22a077bd, 0x002002a0, 0x000000c0 },
index 5b9e625..b3abe4b 100644 (file)
@@ -95,4 +95,4 @@ mac.sat(16) src_sample_b<1>F  Cbn<8,8,1>F     2.017F      { compr align1 };
     /*
      * A = 1.0
      */
-//mov (16)    src_sample_a<1>F 1.0F                        { compr align1 };
+mov (16)    src_sample_a<1>F   1.0F                        { compr align1 };
index 6a76da4..6b99838 100644 (file)
@@ -9,3 +9,4 @@
    { 0x80802048, 0x22007fbd, 0x008d0340, 0xbec8b439 },
    { 0x00802001, 0x240003bc, 0x008d02c0, 0x00000000 },
    { 0x80802048, 0x22407fbd, 0x008d0340, 0x40011687 },
+   { 0x00802001, 0x228003fd, 0x00000000, 0x3f800000 },
index 6a76da4..6b99838 100644 (file)
@@ -9,3 +9,4 @@
    { 0x80802048, 0x22007fbd, 0x008d0340, 0xbec8b439 },
    { 0x00802001, 0x240003bc, 0x008d02c0, 0x00000000 },
    { 0x80802048, 0x22407fbd, 0x008d0340, 0x40011687 },
+   { 0x00802001, 0x228003fd, 0x00000000, 0x3f800000 },
index 5b9e625..b3abe4b 100644 (file)
@@ -95,4 +95,4 @@ mac.sat(16) src_sample_b<1>F  Cbn<8,8,1>F     2.017F      { compr align1 };
     /*
      * A = 1.0
      */
-//mov (16)    src_sample_a<1>F 1.0F                        { compr align1 };
+mov (16)    src_sample_a<1>F   1.0F                        { compr align1 };
index 21fa6fb..6c8c724 100644 (file)
@@ -9,3 +9,4 @@
    { 0x80800048, 0x22007fbd, 0x008d0340, 0xbec8b439 },
    { 0x00800001, 0x240003bc, 0x008d02c0, 0x00000000 },
    { 0x80800048, 0x22407fbd, 0x008d0340, 0x40011687 },
+   { 0x00800001, 0x228003fd, 0x00000000, 0x3f800000 },
index 5b9e625..5cd33e2 100644 (file)
@@ -95,4 +95,4 @@ mac.sat(16) src_sample_b<1>F  Cbn<8,8,1>F     2.017F      { compr align1 };
     /*
      * A = 1.0
      */
-//mov (16)    src_sample_a<1>F 1.0F                        { compr align1 };
+mov (16)    src_sample_a<1>F   1.0F        { compr align1 };
index 21fa6fb..6c8c724 100644 (file)
@@ -9,3 +9,4 @@
    { 0x80800048, 0x22007fbd, 0x008d0340, 0xbec8b439 },
    { 0x00800001, 0x240003bc, 0x008d02c0, 0x00000000 },
    { 0x80800048, 0x22407fbd, 0x008d0340, 0x40011687 },
+   { 0x00800001, 0x228003fd, 0x00000000, 0x3f800000 },