1848b8605Smrg/************************************************************************** 2848b8605Smrg * 3848b8605Smrg * Copyright 2009 Younes Manton. 4848b8605Smrg * All Rights Reserved. 5848b8605Smrg * 6848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a 7848b8605Smrg * copy of this software and associated documentation files (the 8848b8605Smrg * "Software"), to deal in the Software without restriction, including 9848b8605Smrg * without limitation the rights to use, copy, modify, merge, publish, 10848b8605Smrg * distribute, sub license, and/or sell copies of the Software, and to 11848b8605Smrg * permit persons to whom the Software is furnished to do so, subject to 12848b8605Smrg * the following conditions: 13848b8605Smrg * 14848b8605Smrg * The above copyright notice and this permission notice (including the 15848b8605Smrg * next paragraph) shall be included in all copies or substantial portions 16848b8605Smrg * of the Software. 17848b8605Smrg * 18848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19848b8605Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20848b8605Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21848b8605Smrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22848b8605Smrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23848b8605Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24848b8605Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25848b8605Smrg * 26848b8605Smrg **************************************************************************/ 27848b8605Smrg 28848b8605Smrg#ifndef vl_mc_h 29848b8605Smrg#define vl_mc_h 30848b8605Smrg 31848b8605Smrg#include "pipe/p_state.h" 32848b8605Smrg#include "pipe/p_video_state.h" 33848b8605Smrg 34848b8605Smrg#include "tgsi/tgsi_ureg.h" 35848b8605Smrg 36848b8605Smrg#include "vl_defines.h" 37848b8605Smrg#include "vl_types.h" 38848b8605Smrg 39848b8605Smrg#define VL_MC_NUM_BLENDERS (1 << VL_NUM_COMPONENTS) 40848b8605Smrg 41848b8605Smrgstruct pipe_context; 42848b8605Smrg 43848b8605Smrgstruct vl_mc 44848b8605Smrg{ 45848b8605Smrg struct pipe_context *pipe; 46848b8605Smrg unsigned buffer_width; 47848b8605Smrg unsigned buffer_height; 48848b8605Smrg unsigned macroblock_size; 49848b8605Smrg 50848b8605Smrg void *rs_state; 51848b8605Smrg 52848b8605Smrg void *blend_clear[VL_MC_NUM_BLENDERS]; 53848b8605Smrg void *blend_add[VL_MC_NUM_BLENDERS]; 54848b8605Smrg void *blend_sub[VL_MC_NUM_BLENDERS]; 55848b8605Smrg void *vs_ref, *vs_ycbcr; 56848b8605Smrg void *fs_ref, *fs_ycbcr, *fs_ycbcr_sub; 57848b8605Smrg void *sampler_ref; 58848b8605Smrg}; 59848b8605Smrg 60848b8605Smrgstruct vl_mc_buffer 61848b8605Smrg{ 62848b8605Smrg bool surface_cleared; 63848b8605Smrg 64848b8605Smrg struct pipe_viewport_state viewport; 65848b8605Smrg struct pipe_framebuffer_state fb_state; 66848b8605Smrg}; 67848b8605Smrg 68848b8605Smrgtypedef void (*vl_mc_ycbcr_vert_shader)(void *priv, struct vl_mc *mc, 69848b8605Smrg struct ureg_program *shader, 70848b8605Smrg unsigned first_output, 71848b8605Smrg struct ureg_dst tex); 72848b8605Smrg 73848b8605Smrgtypedef void (*vl_mc_ycbcr_frag_shader)(void *priv, struct vl_mc *mc, 74848b8605Smrg struct ureg_program *shader, 75848b8605Smrg unsigned first_input, 76848b8605Smrg struct ureg_dst dst); 77848b8605Smrg 78848b8605Smrgbool vl_mc_init(struct vl_mc *renderer, struct pipe_context *pipe, 79848b8605Smrg unsigned picture_width, unsigned picture_height, 80848b8605Smrg unsigned macroblock_size, float scale, 81848b8605Smrg vl_mc_ycbcr_vert_shader vs_callback, 82848b8605Smrg vl_mc_ycbcr_frag_shader fs_callback, 83848b8605Smrg void *callback_priv); 84848b8605Smrg 85848b8605Smrgvoid vl_mc_cleanup(struct vl_mc *renderer); 86848b8605Smrg 87848b8605Smrgbool vl_mc_init_buffer(struct vl_mc *renderer, struct vl_mc_buffer *buffer); 88848b8605Smrg 89848b8605Smrgvoid vl_mc_cleanup_buffer(struct vl_mc_buffer *buffer); 90848b8605Smrg 91848b8605Smrgvoid vl_mc_set_surface(struct vl_mc_buffer *buffer, struct pipe_surface *surface); 92848b8605Smrg 93848b8605Smrgvoid vl_mc_render_ref(struct vl_mc *renderer, struct vl_mc_buffer *buffer, struct pipe_sampler_view *ref); 94848b8605Smrg 95848b8605Smrgvoid vl_mc_render_ycbcr(struct vl_mc *renderer, struct vl_mc_buffer *buffer, unsigned component, unsigned num_instances); 96848b8605Smrg 97848b8605Smrg#endif /* vl_mc_h */ 98