diff options
-rw-r--r-- | i965_drv_video/i965_defines.h | 2 | ||||
-rw-r--r-- | i965_drv_video/i965_drv_video.c | 302 | ||||
-rw-r--r-- | i965_drv_video/i965_drv_video.h | 23 | ||||
-rw-r--r-- | i965_drv_video/i965_media_mpeg2.c | 2 | ||||
-rw-r--r-- | i965_drv_video/i965_render.c | 149 | ||||
-rw-r--r-- | i965_drv_video/intel_driver.h | 1 | ||||
-rw-r--r-- | i965_drv_video/shaders/render/Makefile.am | 6 | ||||
-rw-r--r-- | i965_drv_video/shaders/render/exa_wm_blend_subpicture.g4b | 15 | ||||
-rw-r--r-- | i965_drv_video/shaders/render/exa_wm_blend_subpicture.g4b.gen5 | 15 | ||||
-rw-r--r-- | i965_drv_video/shaders/render/exa_wm_src_sample_argb.g4a (renamed from i965_drv_video/shaders/render/exa_wm_blend_subpicture.g4a) | 50 | ||||
-rw-r--r-- | i965_drv_video/shaders/render/exa_wm_src_sample_argb.g4b | 2 | ||||
-rw-r--r-- | i965_drv_video/shaders/render/exa_wm_src_sample_argb.g4b.gen5 | 2 | ||||
-rw-r--r-- | src/va.c | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | src/va.h | 4 | ||||
-rw-r--r-- | src/x11/dri1_util.c | 1 | ||||
-rw-r--r-- | src/x11/va_x11.c | 76 |
16 files changed, 344 insertions, 308 deletions
diff --git a/i965_drv_video/i965_defines.h b/i965_drv_video/i965_defines.h index e4e5b2d..260d820 100644 --- a/i965_drv_video/i965_defines.h +++ b/i965_drv_video/i965_defines.h @@ -14,7 +14,7 @@ #define CMD_STATE_BASE_ADDRESS CMD(0, 1, 1) #define CMD_STATE_SIP CMD(0, 1, 2) #define CMD_PIPELINE_SELECT CMD(1, 1, 4) -#define CMD_SAMPLER_PALETTE_LOAD CMD(3, 3, 2) +#define CMD_SAMPLER_PALETTE_LOAD CMD(3, 1, 2) #define CMD_MEDIA_STATE_POINTERS CMD(2, 0, 0) #define CMD_MEDIA_OBJECT CMD(2, 1, 0) diff --git a/i965_drv_video/i965_drv_video.c b/i965_drv_video/i965_drv_video.c index d26942d..8f4bfc1 100644 --- a/i965_drv_video/i965_drv_video.c +++ b/i965_drv_video/i965_drv_video.c @@ -39,6 +39,7 @@ #include "i965_media.h" #include "i965_drv_video.h" +#include "i965_defines.h" #define CONFIG_ID_OFFSET 0x01000000 #define CONTEXT_ID_OFFSET 0x02000000 @@ -47,6 +48,48 @@ #define IMAGE_ID_OFFSET 0x0a000000 #define SUBPIC_ID_OFFSET 0x10000000 +enum { + I965_SURFACETYPE_RGBA = 1, + I965_SURFACETYPE_YUV, + I965_SURFACETYPE_INDEXED +}; + +/* List of supported subpicture formats */ +typedef struct { + unsigned int type; + unsigned int format; + VAImageFormat va_format; + unsigned int va_flags; +} i965_subpic_format_map_t; + +static const i965_subpic_format_map_t +i965_subpic_formats_map[I965_MAX_SUBPIC_FORMATS + 1] = { + { I965_SURFACETYPE_INDEXED, I965_SURFACEFORMAT_P4A4_UNORM, + { VA_FOURCC('I','A','4','4'), VA_MSB_FIRST, 8, }, + 0 }, + { I965_SURFACETYPE_INDEXED, I965_SURFACEFORMAT_A4P4_UNORM, + { VA_FOURCC('A','I','4','4'), VA_MSB_FIRST, 8, }, + 0 }, +}; + +static const i965_subpic_format_map_t * +get_subpic_format(const VAImageFormat *va_format) +{ + unsigned int i; + for (i = 0; i < sizeof(i965_subpic_formats_map)/sizeof(i965_subpic_formats_map[0]); i++) { + const i965_subpic_format_map_t * const m = &i965_subpic_formats_map[i]; + if (m->va_format.fourcc == va_format->fourcc && + (m->type == I965_SURFACETYPE_RGBA ? + (m->va_format.byte_order == va_format->byte_order && + m->va_format.red_mask == va_format->red_mask && + m->va_format.green_mask == va_format->green_mask && + m->va_format.blue_mask == va_format->blue_mask && + m->va_format.alpha_mask == va_format->alpha_mask) : 1)) + return m; + } + return NULL; +} + VAStatus i965_QueryConfigProfiles(VADriverContextP ctx, VAProfile *profile_list, /* out */ @@ -293,6 +336,7 @@ i965_CreateSurfaces(VADriverContextP ctx, surfaces[i] = surfaceID; obj_surface->status = VASurfaceReady; + obj_surface->subpic = VA_INVALID_ID; obj_surface->width = width; obj_surface->height = height; obj_surface->size = SIZE_YUV420(width, height); @@ -346,6 +390,9 @@ i965_QueryImageFormats(VADriverContextP ctx, VAImageFormat *format_list, /* out */ int *num_formats) /* out */ { + if (num_formats) + *num_formats = 0; + return VA_STATUS_SUCCESS; } @@ -371,12 +418,19 @@ i965_QuerySubpictureFormats(VADriverContextP ctx, unsigned int *flags, /* out */ unsigned int *num_formats) /* out */ { - /*support 2 subpicture formats*/ - *num_formats = 2; - format_list[0].fourcc=FOURCC_IA44; - format_list[0].byte_order=VA_LSB_FIRST; - format_list[1].fourcc=FOURCC_AI44; - format_list[1].byte_order=VA_LSB_FIRST; + int n; + + for (n = 0; i965_subpic_formats_map[n].va_format.fourcc != 0; n++) { + const i965_subpic_format_map_t * const m = &i965_subpic_formats_map[n]; + if (format_list) + format_list[n] = m->va_format; + if (flags) + flags[n] = m->va_flags; + } + + if (num_formats) + *num_formats = n; + return VA_STATUS_SUCCESS; } @@ -394,25 +448,27 @@ i965_CreateSubpicture(VADriverContextP ctx, VASubpictureID *subpicture) /* out */ { struct i965_driver_data *i965 = i965_driver_data(ctx); - VAStatus vaStatus = VA_STATUS_SUCCESS; VASubpictureID subpicID = NEW_SUBPIC_ID() struct object_subpic *obj_subpic = SUBPIC(subpicID); + if (!obj_subpic) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + struct object_image *obj_image = IMAGE(image); - - if (NULL == obj_subpic) { - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; - } - if (NULL == obj_image) { - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; - } + if (!obj_image) + return VA_STATUS_ERROR_INVALID_IMAGE; + + const i965_subpic_format_map_t * const m = get_subpic_format(&obj_image->image.format); + if (!m) + return VA_STATUS_ERROR_UNKNOWN; /* XXX: VA_STATUS_ERROR_UNSUPPORTED_FORMAT? */ + *subpicture = subpicID; - obj_subpic->image = image; - obj_subpic->width = obj_image->width; - obj_subpic->height = obj_image->height; - obj_subpic->bo = obj_image->bo; - - return vaStatus; + obj_subpic->image = image; + obj_subpic->format = m->format; + obj_subpic->width = obj_image->image.width; + obj_subpic->height = obj_image->image.height; + obj_subpic->bo = obj_image->bo; + return VA_STATUS_SUCCESS; } VAStatus @@ -434,27 +490,6 @@ i965_SetSubpictureImage(VADriverContextP ctx, return VA_STATUS_SUCCESS; } -/* - * pointer to an array holding the palette data. The size of the array is - * num_palette_entries * entry_bytes in size. The order of the components - * in the palette is described by the component_order in VASubpicture struct - */ -VAStatus -i965_SetSubpicturePalette(VADriverContextP ctx, - VASubpictureID subpicture, - unsigned char *palette) -{ - /*set palette in shader,so the following code is unused*/ - struct i965_driver_data *i965 = i965_driver_data(ctx); - VAStatus vaStatus = VA_STATUS_SUCCESS; - struct object_subpic *obj_subpic = SUBPIC(subpicture); - if (NULL == obj_subpic) { - vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; - } - memcpy(obj_subpic->palette, palette, 3*16); - return VA_STATUS_SUCCESS; -} - VAStatus i965_SetSubpictureChromakey(VADriverContextP ctx, VASubpictureID subpicture, @@ -486,8 +521,6 @@ i965_AssociateSubpicture(VADriverContextP ctx, short dest_y, unsigned short dest_width, unsigned short dest_height, - unsigned short width, - unsigned short height, /* * whether to enable chroma-keying or global-alpha * see VA_SUBPICTURE_XXX values @@ -495,22 +528,24 @@ i965_AssociateSubpicture(VADriverContextP ctx, unsigned int flags) { struct i965_driver_data *i965 = i965_driver_data(ctx); - VAStatus vaStatus = VA_STATUS_SUCCESS; - /*only ipicture*/ - - struct object_surface *obj_surface = SURFACE(*target_surfaces); struct object_subpic *obj_subpic = SUBPIC(subpicture); + int i; - if (NULL == obj_surface) { - vaStatus = VA_STATUS_ERROR_INVALID_CONFIG; - return vaStatus; - } - - obj_subpic->dstx = dest_x; - obj_subpic->dsty = dest_y; - - obj_surface->subpic = subpicture; + obj_subpic->src_rect.x = src_x; + obj_subpic->src_rect.y = src_y; + obj_subpic->src_rect.width = src_width; + obj_subpic->src_rect.height = src_height; + obj_subpic->dst_rect.x = dest_x; + obj_subpic->dst_rect.y = dest_y; + obj_subpic->dst_rect.width = dest_width; + obj_subpic->dst_rect.height = dest_height; + for (i = 0; i < num_surfaces; i++) { + struct object_surface *obj_surface = SURFACE(target_surfaces[i]); + if (!obj_surface) + return VA_STATUS_ERROR_INVALID_SURFACE; + obj_surface->subpic = subpicture; + } return VA_STATUS_SUCCESS; } @@ -521,6 +556,16 @@ i965_DeassociateSubpicture(VADriverContextP ctx, VASurfaceID *target_surfaces, int num_surfaces) { + struct i965_driver_data *i965 = i965_driver_data(ctx); + int i; + + for (i = 0; i < num_surfaces; i++) { + struct object_surface *obj_surface = SURFACE(target_surfaces[i]); + if (!obj_surface) + return VA_STATUS_ERROR_INVALID_SURFACE; + if (obj_surface->subpic == subpicture) + obj_surface->subpic = VA_INVALID_ID; + } return VA_STATUS_SUCCESS; } @@ -1031,8 +1076,10 @@ i965_QueryDisplayAttributes(VADriverContextP ctx, VADisplayAttribute *attr_list, /* out */ int *num_attributes) /* out */ { - /* TODO */ - return VA_STATUS_ERROR_UNKNOWN; + if (num_attributes) + *num_attributes = 0; + + return VA_STATUS_SUCCESS; } /* @@ -1116,43 +1163,89 @@ i965_destroy_heap(struct object_heap *heap, } +VAStatus +i965_DestroyImage(VADriverContextP ctx, VAImageID image); VAStatus i965_CreateImage(VADriverContextP ctx, VAImageFormat *format, int width, int height, - VAImage *image) /* out */ + VAImage *out_image) /* out */ { struct i965_driver_data *i965 = i965_driver_data(ctx); - VAStatus va_status; - /*we will receive the actual subpicture size from the player,now we assume it is 720*32*/ - char subpic_buf[width*height]; - int subpic_size = 720*32; - unsigned int img_buf_id; + struct object_image *obj_image; + VAStatus va_status = VA_STATUS_ERROR_OPERATION_FAILED; + VAImageID image_id; + unsigned int width2, height2, size2, size; - image->image_id = NEW_IMAGE_ID(); - struct object_image *obj_image = IMAGE(image->image_id); + out_image->image_id = VA_INVALID_ID; + out_image->buf = VA_INVALID_ID; - /*assume we got IA44 in format[0]*/ - image->format = *format; - - /*create empty buffer*/ - va_status = i965_CreateBuffer(ctx, 0, VAImageBufferType, - subpic_size, 1, subpic_buf, &img_buf_id); - assert( VA_STATUS_SUCCESS == va_status ); - struct object_buffer *obj_buf = BUFFER(img_buf_id); - - image->buf = img_buf_id; - image->width = width; - image->height = height; - - obj_image->width = width; - obj_image->height = height; - obj_image->size = subpic_size; - obj_image->bo = obj_buf->buffer_store->bo; - + image_id = NEW_IMAGE_ID(); + if (image_id == VA_INVALID_ID) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + + obj_image = IMAGE(image_id); + if (!obj_image) + return VA_STATUS_ERROR_ALLOCATION_FAILED; + obj_image->bo = NULL; + obj_image->palette = NULL; + + VAImage * const image = &obj_image->image; + image->image_id = image_id; + image->buf = VA_INVALID_ID; + + size = width * height; + width2 = (width + 1) / 2; + height2 = (height + 1) / 2; + size2 = width2 * height2; + + image->num_palette_entries = 0; + image->entry_bytes = 0; + memset(image->component_order, 0, sizeof(image->component_order)); + + switch (format->fourcc) { + case VA_FOURCC('I','A','4','4'): + case VA_FOURCC('A','I','4','4'): + image->num_planes = 1; + image->pitches[0] = width; + image->offsets[0] = 0; + image->data_size = image->offsets[0] + image->pitches[0] * height; + image->num_palette_entries = 16; + image->entry_bytes = 3; + image->component_order[0] = 'R'; + image->component_order[1] = 'G'; + image->component_order[2] = 'B'; + break; + default: + goto error; + } + + va_status = i965_CreateBuffer(ctx, 0, VAImageBufferType, + image->data_size, 1, NULL, &image->buf); + if (va_status != VA_STATUS_SUCCESS) + goto error; + + obj_image->bo = BUFFER(image->buf)->buffer_store->bo; + + if (image->num_palette_entries > 0 && image->entry_bytes > 0) { + obj_image->palette = malloc(image->num_palette_entries * sizeof(obj_image->palette)); + if (!obj_image->palette) + goto error; + } + + image->image_id = image_id; + image->format = *format; + image->width = width; + image->height = height; + + *out_image = *image; return VA_STATUS_SUCCESS; + + error: + i965_DestroyImage(ctx, image_id); + return va_status; } VAStatus i965_DeriveImage(VADriverContextP ctx, @@ -1175,18 +1268,48 @@ i965_DestroyImage(VADriverContextP ctx, VAImageID image) struct i965_driver_data *i965 = i965_driver_data(ctx); struct object_image *obj_image = IMAGE(image); - i965_DestroyBuffer(ctx, image); - + if (!obj_image) + return VA_STATUS_SUCCESS; + + if (obj_image->image.buf != VA_INVALID_ID) { + i965_DestroyBuffer(ctx, obj_image->image.buf); + obj_image->image.buf = VA_INVALID_ID; + } + + if (obj_image->palette) { + free(obj_image->palette); + obj_image->palette = NULL; + } + i965_destroy_image(&i965->image_heap, (struct object_base *)obj_image); return VA_STATUS_SUCCESS; } +/* + * pointer to an array holding the palette data. The size of the array is + * num_palette_entries * entry_bytes in size. The order of the components + * in the palette is described by the component_order in VASubpicture struct + */ VAStatus i965_SetImagePalette(VADriverContextP ctx, VAImageID image, unsigned char *palette) { + struct i965_driver_data *i965 = i965_driver_data(ctx); + unsigned int i; + + struct object_image *obj_image = IMAGE(image); + if (!obj_image) + return VA_STATUS_ERROR_INVALID_IMAGE; + + if (!obj_image->palette) + return VA_STATUS_ERROR_ALLOCATION_FAILED; /* XXX: unpaletted/error */ + + for (i = 0; i < obj_image->image.num_palette_entries; i++) + obj_image->palette[i] = (((unsigned int)palette[3*i + 0] << 16) | + ((unsigned int)palette[3*i + 1] << 8) | + (unsigned int)palette[3*i + 2]); return VA_STATUS_SUCCESS; } @@ -1274,7 +1397,7 @@ i965_PutSurface(VADriverContextP ctx, srcx, srcy, srcw, srch, destx, desty, destw, desth); obj_surface = SURFACE(surface); - if(obj_surface->subpic != 0) { + if(obj_surface->subpic != VA_INVALID_ID) { i965_render_put_subpic(ctx, surface, srcx, srcy, srcw, srch, destx, desty, destw, desth); @@ -1317,8 +1440,8 @@ __vaDriverInit_0_31( VADriverContextP ctx ) struct i965_driver_data *i965; int result; - ctx->version_major = 0; - ctx->version_minor = 29; + ctx->version_major = VA_MAJOR_VERSION; + ctx->version_minor = VA_MINOR_VERSION; ctx->max_profiles = I965_MAX_PROFILES; ctx->max_entrypoints = I965_MAX_ENTRYPOINTS; ctx->max_attributes = I965_MAX_CONFIG_ATTRIBUTES; @@ -1361,7 +1484,6 @@ __vaDriverInit_0_31( VADriverContextP ctx ) ctx->vtable.vaCreateSubpicture = i965_CreateSubpicture; ctx->vtable.vaDestroySubpicture = i965_DestroySubpicture; ctx->vtable.vaSetSubpictureImage = i965_SetSubpictureImage; - //ctx->vtable.vaSetSubpicturePalette = i965_SetSubpicturePalette; ctx->vtable.vaSetSubpictureChromakey = i965_SetSubpictureChromakey; ctx->vtable.vaSetSubpictureGlobalAlpha = i965_SetSubpictureGlobalAlpha; ctx->vtable.vaAssociateSubpicture = i965_AssociateSubpicture; diff --git a/i965_drv_video/i965_drv_video.h b/i965_drv_video/i965_drv_video.h index 1771b0d..c95c799 100644 --- a/i965_drv_video/i965_drv_video.h +++ b/i965_drv_video/i965_drv_video.h @@ -42,7 +42,7 @@ #define I965_MAX_ENTRYPOINTS 5 #define I965_MAX_CONFIG_ATTRIBUTES 10 #define I965_MAX_IMAGE_FORMATS 10 -#define I965_MAX_SUBPIC_FORMATS 4 +#define I965_MAX_SUBPIC_FORMATS 2 #define I965_MAX_DISPLAY_ATTRIBUTES 4 #define I965_STR_VENDOR "i965 Driver 0.1" @@ -91,7 +91,7 @@ struct object_surface struct object_base base; VASurfaceStatus status; VASubpictureID subpic; - int width; + int width; int height; int size; dri_bo *bo; @@ -106,24 +106,25 @@ struct object_buffer int size_element; VABufferType type; }; + struct object_image { struct object_base base; - int width; - int height; - int size; + VAImage image; dri_bo *bo; + unsigned int *palette; }; + struct object_subpic { struct object_base base; VAImageID image; - int dstx; - int dsty; - int width; - int height; - unsigned char palette[3][16]; - dri_bo *bo; + VARectangle src_rect; + VARectangle dst_rect; + unsigned int format; + int width; + int height; + dri_bo *bo; }; diff --git a/i965_drv_video/i965_media_mpeg2.c b/i965_drv_video/i965_media_mpeg2.c index 17b4679..6a14e9e 100644 --- a/i965_drv_video/i965_media_mpeg2.c +++ b/i965_drv_video/i965_media_mpeg2.c @@ -868,7 +868,7 @@ i965_media_mpeg2_objects(VADriverContextP ctx, struct decode_state *decode_state I915_GEM_DOMAIN_SAMPLER, 0, slice_param->slice_data_offset + (slice_param->macroblock_offset >> 3)); OUT_BATCH(ctx, - ((0 << 24) | + ((slice_param->slice_horizontal_position << 24) | (slice_param->slice_vertical_position << 16) | (127 << 8) | (slice_param->macroblock_offset & 0x7))); diff --git a/i965_drv_video/i965_render.c b/i965_drv_video/i965_render.c index e897dcd..f3e89c2 100644 --- a/i965_drv_video/i965_render.c +++ b/i965_drv_video/i965_render.c @@ -70,7 +70,7 @@ static const unsigned int ps_subpic_kernel_static[][4] = { #include "shaders/render/exa_wm_xy.g4b" #include "shaders/render/exa_wm_src_affine.g4b" -#include "shaders/render/exa_wm_blend_subpicture.g4b" +#include "shaders/render/exa_wm_src_sample_argb.g4b" #include "shaders/render/exa_wm_write.g4b" }; @@ -92,7 +92,7 @@ static const unsigned int ps_subpic_kernel_static_gen5[][4] = { #include "shaders/render/exa_wm_xy.g4b.gen5" #include "shaders/render/exa_wm_src_affine.g4b.gen5" -#include "shaders/render/exa_wm_blend_subpicture.g4b.gen5" +#include "shaders/render/exa_wm_src_sample_argb.g4b.gen5" #include "shaders/render/exa_wm_write.g4b.gen5" }; @@ -580,12 +580,13 @@ i965_render_src_surface_state(VADriverContextP ctx, render_state->wm.surface[index] = ss_bo; render_state->wm.sampler_count++; } + static void i965_subpic_render_src_surface_state(VADriverContextP ctx, int index, dri_bo *region, unsigned long offset, - int w, int h) + int w, int h, int format) { struct i965_driver_data *i965 = i965_driver_data(ctx); struct i965_render_state *render_state = &i965->render_state; @@ -601,7 +602,7 @@ i965_subpic_render_src_surface_state(VADriverContextP ctx, ss = ss_bo->virtual; memset(ss, 0, sizeof(*ss)); ss->ss0.surface_type = I965_SURFACE_2D; - ss->ss0.surface_format = I965_SURFACEFORMAT_R8_UNORM; + ss->ss0.surface_format = format; ss->ss0.writedisable_alpha = 0; ss->ss0.writedisable_red = 0; ss->ss0.writedisable_green = 0; @@ -677,8 +678,8 @@ i965_subpic_render_src_surfaces_state(VADriverContextP ctx, region = obj_surface->bo; subpic_region = obj_image->bo; /*subpicture surface*/ - i965_subpic_render_src_surface_state(ctx, 1, subpic_region, 0, obj_image->width, obj_image->height); - i965_subpic_render_src_surface_state(ctx, 2, subpic_region, 0, obj_image->width, obj_image->height); + i965_subpic_render_src_surface_state(ctx, 1, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->format); + i965_subpic_render_src_surface_state(ctx, 2, subpic_region, 0, obj_subpic->width, obj_subpic->height, obj_subpic->format); } static void @@ -788,58 +789,57 @@ i965_render_binding_table(VADriverContextP ctx) static void i965_subpic_render_upload_vertex(VADriverContextP ctx, - VASurfaceID surface, - short srcx, - short srcy, - unsigned short srcw, - unsigned short srch, - short destx, - short desty, - unsigned short destw, - unsigned short desth) + VASurfaceID surface, + const VARectangle *output_rect) { - struct i965_driver_data *i965 = i965_driver_data(ctx); + struct i965_driver_data *i965 = i965_driver_data(ctx); struct i965_render_state *render_state = &i965->render_state; - struct intel_region *dest_region = render_state->draw_region; - struct object_surface *obj_surface; - struct object_subpic *obj_subpic; - float *vb; - float src_scale_x, src_scale_y; - int i, width, height; - obj_surface = SURFACE(surface); - obj_subpic = SUBPIC(obj_surface->subpic); - assert(obj_surface); - assert(obj_subpic); - - int box_x1 = dest_region->x + obj_subpic->dstx; - int box_y1 = dest_region->y + obj_subpic->dsty; - int box_x2 = box_x1 + obj_subpic->width; - int box_y2 = box_y1 + obj_subpic->height; - - width = obj_surface->width; - height = obj_surface->height; - src_scale_x = ((float)srcw / width) / (float)destw; - src_scale_y = ((float)srch / height) / (float)desth; + struct object_surface *obj_surface = SURFACE(surface); + struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic); + + const float psx = (float)obj_surface->width / (float)obj_subpic->width; + const float psy = (float)obj_surface->height / (float)obj_subpic->height; + const float ssx = (float)output_rect->width / (float)obj_surface->width; + const float ssy = (float)output_rect->height / (float)obj_surface->height; + const float sx = psx * ssx; + const float sy = psy * ssy; + float *vb, tx1, tx2, ty1, ty2, x1, x2, y1, y2; + int i = 0; + + VARectangle dst_rect; + dst_rect.x = output_rect->x + sx * (float)obj_subpic->dst_rect.x; + dst_rect.y = output_rect->y + sx * (float)obj_subpic->dst_rect.y; + dst_rect.width = sx * (float)obj_subpic->dst_rect.width; + dst_rect.height = sy * (float)obj_subpic->dst_rect.height; dri_bo_map(render_state->vb.vertex_buffer, 1); assert(render_state->vb.vertex_buffer->virtual); vb = render_state->vb.vertex_buffer->virtual; - /*vertex covers the full subpicture*/ - i = 0; - vb[i++] = 1; - vb[i++] = 1; - vb[i++] = (float)box_x2; - vb[i++] = (float)box_y2; - - vb[i++] = 0.0; - vb[i++] = 1; - vb[i++] = (float)box_x1; - vb[i++] = (float)box_y2; - vb[i++] = 0.0; - vb[i++] = 0.0; - vb[i++] = (float)box_x1; - vb[i++] = (float)box_y1; + tx1 = (float)obj_subpic->src_rect.x / (float)obj_subpic->width; + ty1 = (float)obj_subpic->src_rect.y / (float)obj_subpic->height; + tx2 = (float)(obj_subpic->src_rect.x + obj_subpic->src_rect.width) / (float)obj_subpic->width; + ty2 = (float)(obj_subpic->src_rect.y + obj_subpic->src_rect.height) / (float)obj_subpic->height; + + x1 = (float)dst_rect.x; + y1 = (float)dst_rect.y; + x2 = (float)(dst_rect.x + dst_rect.width); + y2 = (float)(dst_rect.y + dst_rect.height); + + vb[i++] = tx2; + vb[i++] = ty2; + vb[i++] = x2; + vb[i++] = y2; + + vb[i++] = tx1; + vb[i++] = ty2; + vb[i++] = x1; + vb[i++] = y2; + + vb[i++] = tx1; + vb[i++] = ty1; + vb[i++] = x1; + vb[i++] = y1; dri_bo_unmap(render_state->vb.vertex_buffer); } @@ -947,9 +947,13 @@ i965_subpic_render_state_setup(VADriverContextP ctx, i965_render_cc_viewport(ctx); i965_subpic_render_cc_unit(ctx); i965_render_binding_table(ctx); - i965_subpic_render_upload_vertex(ctx, surface, - srcx, srcy, srcw, srch, - destx, desty, destw, desth); + + VARectangle output_rect; + output_rect.x = destx; + output_rect.y = desty; + output_rect.width = destw; + output_rect.height = desth; + i965_subpic_render_upload_vertex(ctx, surface, &output_rect); } @@ -1162,21 +1166,31 @@ i965_render_vertex_elements(VADriverContextP ctx) } } -void -i965_render_upload_palette(VADriverContextP ctx) +static void +i965_render_upload_image_palette( + VADriverContextP ctx, + VAImageID image_id, + unsigned int alpha +) { - BEGIN_BATCH(ctx, 17); - OUT_BATCH(ctx, CMD_SAMPLER_PALETTE_LOAD | 15); + struct i965_driver_data *i965 = i965_driver_data(ctx); + unsigned int i; + + struct object_image *obj_image = IMAGE(image_id); + assert(obj_image); + + if (obj_image->image.num_palette_entries == 0) + return; + + BEGIN_BATCH(ctx, 1 + obj_image->image.num_palette_entries); + OUT_BATCH(ctx, CMD_SAMPLER_PALETTE_LOAD | (obj_image->image.num_palette_entries - 1)); /*fill palette*/ //int32_t out[16]; //0-23:color 23-31:alpha - int32_t i,c; - for(i = 0; i < 16; i ++){ - c = i*16; //16 colors - OUT_BATCH(ctx,c<<24/*alpha*/|c<<16/*R*/|c<<8/*G*/|c/*B*/);//c<<24/*alpha*/|c<<16/*R*/|c<<8/*G*/|c/*B*/); - } - + for (i = 0; i < obj_image->image.num_palette_entries; i++) + OUT_BATCH(ctx, (alpha << 24) | obj_image->palette[i]); ADVANCE_BATCH(ctx); } + static void i965_render_startup(VADriverContextP ctx) { @@ -1284,7 +1298,6 @@ i965_subpic_render_pipeline_setup(VADriverContextP ctx) i965_render_binding_table_pointers(ctx); i965_render_constant_color(ctx); i965_render_pipelined_pointers(ctx); - //i965_render_upload_palette(ctx); i965_render_urb_layout(ctx); i965_render_cs_urb_layout(ctx); i965_render_drawing_rectangle(ctx); @@ -1412,11 +1425,17 @@ i965_render_put_subpic(VADriverContextP ctx, unsigned short destw, unsigned short desth) { + struct i965_driver_data *i965 = i965_driver_data(ctx); + struct object_surface *obj_surface = SURFACE(surface); + struct object_subpic *obj_subpic = SUBPIC(obj_surface->subpic); + assert(obj_subpic); + i965_render_initialize(ctx); i965_subpic_render_state_setup(ctx, surface, srcx, srcy, srcw, srch, destx, desty, destw, desth); i965_subpic_render_pipeline_setup(ctx); + i965_render_upload_image_palette(ctx, obj_subpic->image, 0xff); intel_batchbuffer_flush(ctx); } diff --git a/i965_drv_video/intel_driver.h b/i965_drv_video/intel_driver.h index f768703..84df0aa 100644 --- a/i965_drv_video/intel_driver.h +++ b/i965_drv_video/intel_driver.h @@ -43,6 +43,7 @@ struct intel_batchbuffer; #define ALIGN(i, n) (((i) + (n) - 1) & ~((n) - 1)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) #define SET_BLOCKED_SIGSET() do { \ sigset_t bl_mask; \ diff --git a/i965_drv_video/shaders/render/Makefile.am b/i965_drv_video/shaders/render/Makefile.am index f38c234..fb9b11e 100644 --- a/i965_drv_video/shaders/render/Makefile.am +++ b/i965_drv_video/shaders/render/Makefile.am @@ -7,27 +7,27 @@ INTEL_G4A = \ exa_sf.g4a \ exa_wm_xy.g4a \ exa_wm_src_affine.g4a \ + exa_wm_src_sample_argb.g4a \ exa_wm_src_sample_planar.g4a \ exa_wm_yuv_rgb.g4a \ - exa_wm_blend_subpicture.g4a \ exa_wm_write.g4a INTEL_G4B = \ exa_sf.g4b \ exa_wm_xy.g4b \ exa_wm_src_affine.g4b \ + exa_wm_src_sample_argb.g4b \ exa_wm_src_sample_planar.g4b \ exa_wm_yuv_rgb.g4b \ - exa_wm_blend_subpicture.g4b \ exa_wm_write.g4b INTEL_G4B_GEN5 = \ exa_sf.g4b.gen5 \ exa_wm_xy.g4b.gen5 \ exa_wm_src_affine.g4b.gen5 \ + exa_wm_src_sample_argb.g4b.gen5 \ exa_wm_src_sample_planar.g4b.gen5 \ exa_wm_yuv_rgb.g4b.gen5 \ - exa_wm_blend_subpicture.g4b.gen5 \ exa_wm_write.g4b.gen5 EXTRA_DIST = $(INTEL_G4I) \ diff --git a/i965_drv_video/shaders/render/exa_wm_blend_subpicture.g4b b/i965_drv_video/shaders/render/exa_wm_blend_subpicture.g4b deleted file mode 100644 index bbc75c0..0000000 --- a/i965_drv_video/shaders/render/exa_wm_blend_subpicture.g4b +++ /dev/null @@ -1,15 +0,0 @@ - { 0x00000201, 0x20080061, 0x00000000, 0x0000e000 }, - { 0x01800031, 0x22001d29, 0x008d0000, 0x02520001 }, - { 0x01800031, 0x21c01d29, 0x008d0000, 0x02520201 }, - { 0x01800031, 0x22401d29, 0x008d0000, 0x02520401 }, - { 0x00600001, 0x228003bd, 0x008d01c0, 0x00000000 }, - { 0x00600001, 0x22a003bd, 0x008d01e0, 0x00000000 }, - { 0x00600040, 0x21c07fbd, 0x008d01c0, 0x3f000000 }, - { 0x00600040, 0x21e07fbd, 0x008d01e0, 0x3f000000 }, - { 0x00600040, 0x22007fbd, 0x008d0200, 0x3f000000 }, - { 0x00600040, 0x22207fbd, 0x008d0220, 0x3f000000 }, - { 0x00600040, 0x22407fbd, 0x008d0240, 0x3f000000 }, - { 0x00600040, 0x22607fbd, 0x008d0260, 0x3f000000 }, - { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, - { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, - { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, diff --git a/i965_drv_video/shaders/render/exa_wm_blend_subpicture.g4b.gen5 b/i965_drv_video/shaders/render/exa_wm_blend_subpicture.g4b.gen5 deleted file mode 100644 index 0e7534f..0000000 --- a/i965_drv_video/shaders/render/exa_wm_blend_subpicture.g4b.gen5 +++ /dev/null @@ -1,15 +0,0 @@ - { 0x00000201, 0x20080061, 0x00000000, 0x0000e000 }, - { 0x01800031, 0x22001d29, 0x208d0000, 0x0a2a0001 }, - { 0x01800031, 0x21c01d29, 0x208d0000, 0x0a2a0201 }, - { 0x01800031, 0x22401d29, 0x208d0000, 0x0a2a0401 }, - { 0x00600001, 0x228003bd, 0x008d01c0, 0x00000000 }, - { 0x00600001, 0x22a003bd, 0x008d01e0, 0x00000000 }, - { 0x00600040, 0x21c07fbd, 0x008d01c0, 0x3f000000 }, - { 0x00600040, 0x21e07fbd, 0x008d01e0, 0x3f000000 }, - { 0x00600040, 0x22007fbd, 0x008d0200, 0x3f000000 }, - { 0x00600040, 0x22207fbd, 0x008d0220, 0x3f000000 }, - { 0x00600040, 0x22407fbd, 0x008d0240, 0x3f000000 }, - { 0x00600040, 0x22607fbd, 0x008d0260, 0x3f000000 }, - { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, - { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, - { 0x0000007e, 0x00000000, 0x00000000, 0x00000000 }, diff --git a/i965_drv_video/shaders/render/exa_wm_blend_subpicture.g4a b/i965_drv_video/shaders/render/exa_wm_src_sample_argb.g4a index 2d2cd31..c20f53f 100644 --- a/i965_drv_video/shaders/render/exa_wm_blend_subpicture.g4a +++ b/i965_drv_video/shaders/render/exa_wm_src_sample_argb.g4a @@ -25,7 +25,8 @@ * Keith Packard <keithp@keithp.com> */ -/* Sample the src surface in planar format */ +/* Sample the src surface */ + include(`exa_wm.g4i') /* prepare sampler read back gX register, which would be written back to output */ @@ -33,51 +34,14 @@ include(`exa_wm.g4i') /* use simd16 sampler, param 0 is u, param 1 is v. */ /* 'payload' loading, assuming tex coord start from g4 */ -/* load r */ -mov (1) g0.8<1>UD 0x0000e000UD { align1 mask_disable }; +/* load argb */ +mov (1) g0.8<1>UD 0x00000000UD { align1 mask_disable }; /* src_msg will be copied with g0, as it contains send desc */ /* emit sampler 'send' cmd */ - - -/* sample Y */ -send (16) src_msg_ind /* msg reg index */ - src_sample_g<1>UW /* readback */ - g0<8,8,1>UW /* copy to msg start reg*/ - sampler (1,0,F) /* sampler message description, (binding_table,sampler_index,datatype)*/ - mlen 5 rlen 2 {align1}; - -/* sample U (Cr) */ -send (16) src_msg_ind /* msg reg index */ - src_sample_r<1>UW /* readback */ - g0<8,8,1>UW /* copy to msg start reg*/ - sampler (1,2,F) /* sampler message description, (binding_table,sampler_index,datatype) - /* here(src->dst) we should use src_sampler and src_surface */ - mlen 5 rlen 2 { align1 }; /* required message len 5, readback len 8 */ - -/* sample V (Cb) */ send (16) src_msg_ind /* msg reg index */ - src_sample_b<1>UW /* readback */ + src_sample_base<1>UW /* readback */ g0<8,8,1>UW /* copy to msg start reg*/ - sampler (1,4,F) /* sampler message description, (binding_table,sampler_index,datatype) + 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 2 { align1 }; /* required message len 5, readback len 8 */ - -/*extract alpha value, alpha value stores in one float with color value, because the color value is small, -we can neglect it when doing alpha blend*/ -mov (8) src_sample_a<1>F g14<8,8,1>F { align1 }; -mov (8) src_sample_a_23<1>F g15<8,8,1>F { align1 }; - - -/*set subtitle color*/ -add (8) g14<1>F g14<8,8,1>F 0.5F { align1 }; -add (8) g15<1>F g15<8,8,1>F 0.5F { align1 }; -add (8) g16<1>F g16<8,8,1>F 0.5F { align1 }; -add (8) g17<1>F g17<8,8,1>F 0.5F { align1 }; -add (8) g18<1>F g18<8,8,1>F 0.5F { align1 }; -add (8) g19<1>F g19<8,8,1>F 0.5F { align1 }; - -nop; -nop; -nop; - + mlen 5 rlen 8 { align1 }; /* required message len 5, readback len 8 */ diff --git a/i965_drv_video/shaders/render/exa_wm_src_sample_argb.g4b b/i965_drv_video/shaders/render/exa_wm_src_sample_argb.g4b new file mode 100644 index 0000000..c5b9274 --- /dev/null +++ b/i965_drv_video/shaders/render/exa_wm_src_sample_argb.g4b @@ -0,0 +1,2 @@ + { 0x00000201, 0x20080061, 0x00000000, 0x00000000 }, + { 0x01800031, 0x21c01d29, 0x008d0000, 0x02580001 }, diff --git a/i965_drv_video/shaders/render/exa_wm_src_sample_argb.g4b.gen5 b/i965_drv_video/shaders/render/exa_wm_src_sample_argb.g4b.gen5 new file mode 100644 index 0000000..f8cb41e --- /dev/null +++ b/i965_drv_video/shaders/render/exa_wm_src_sample_argb.g4b.gen5 @@ -0,0 +1,2 @@ + { 0x00000201, 0x20080061, 0x00000000, 0x00000000 }, + { 0x01800031, 0x21c01d29, 0x208d0000, 0x0a8a0001 }, @@ -313,6 +313,8 @@ const char *vaErrorStr(VAStatus error_status) return "resolution not supported"; case VA_STATUS_ERROR_UNIMPLEMENTED: return "the requested function is not implemented"; + case VA_STATUS_ERROR_SURFACE_IN_DISPLAYING: + return "surface is in displaying (may by overlay)" ; case VA_STATUS_ERROR_UNKNOWN: return "unknown libva error"; } @@ -127,7 +127,8 @@ typedef int VAStatus; /* Return status type from functions */ #define VA_STATUS_ERROR_FLAG_NOT_SUPPORTED 0x00000011 #define VA_STATUS_ERROR_INVALID_PARAMETER 0x00000012 #define VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED 0x00000013 -#define VA_STATUS_ERROR_UNIMPLEMENTED 0x00000014 +#define VA_STATUS_ERROR_UNIMPLEMENTED 0x00000014 +#define VA_STATUS_ERROR_SURFACE_IN_DISPLAYING 0x00000015 #define VA_STATUS_ERROR_UNKNOWN 0xFFFFFFFF /* @@ -569,6 +570,7 @@ typedef struct _VASliceParameterBufferMPEG2 unsigned int slice_data_offset;/* the offset to the first byte of slice data */ unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */ unsigned int macroblock_offset;/* the offset to the first bit of MB from the first byte of slice data */ + unsigned int slice_horizontal_position; unsigned int slice_vertical_position; int quantiser_scale_code; int intra_slice_flag; diff --git a/src/x11/dri1_util.c b/src/x11/dri1_util.c index b3db5b4..3e67e2a 100644 --- a/src/x11/dri1_util.c +++ b/src/x11/dri1_util.c @@ -107,7 +107,6 @@ isDRI1Connected(VADriverContextP ctx, char **driver_name) dri_state->fd = drmOpenOnce(NULL, BusID, &newlyopened); XFree(BusID); - assert(dri_state->fd >= 0); if (dri_state->fd < 0) goto err_out1; diff --git a/src/x11/va_x11.c b/src/x11/va_x11.c index 9de904e..5908fbe 100644 --- a/src/x11/va_x11.c +++ b/src/x11/va_x11.c @@ -42,26 +42,6 @@ static VADisplayContextP pDisplayContexts = NULL; -static void va_errorMessage(const char *msg, ...) -{ - va_list args; - - fprintf(stderr, "libva error: "); - va_start(args, msg); - vfprintf(stderr, msg, args); - va_end(args); -} - -static void va_infoMessage(const char *msg, ...) -{ - va_list args; - - fprintf(stderr, "libva: "); - va_start(args, msg); - vfprintf(stderr, msg, args); - va_end(args); -} - static int va_DisplayContextIsValid ( VADisplayContextP pDisplayContext ) @@ -132,49 +112,21 @@ static VAStatus va_NVCTRL_GetDriverName ( ) { VADriverContextP ctx = pDisplayContext->pDriverContext; - VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN; - int direct_capable; - int driver_major; - int driver_minor; - int driver_patch; - Bool result = True; - char *nvidia_driver_name = NULL; + int direct_capable, driver_major, driver_minor, driver_patch; + Bool result; - if (result) - { - result = VA_NVCTRLQueryDirectRenderingCapable(ctx->x11_dpy, ctx->x11_screen, &direct_capable); - if (!result) - { - va_errorMessage("VA_NVCTRLQueryDirectRenderingCapable failed\n"); - } - } - if (result) - { - result = direct_capable; - if (!result) - { - va_errorMessage("VA_NVCTRLQueryDirectRenderingCapable returned false\n"); - } - } - if (result) - { - result = VA_NVCTRLGetClientDriverName(ctx->x11_dpy, ctx->x11_screen, &driver_major, &driver_minor, - &driver_patch, &nvidia_driver_name); - if (!result) - { - va_errorMessage("VA_NVCTRLGetClientDriverName returned false\n"); - } - } - if (result) - { - vaStatus = VA_STATUS_SUCCESS; - va_infoMessage("va_NVCTRL_GetDriverName: %d.%d.%d %s (screen %d)\n", - driver_major, driver_minor, driver_patch, - nvidia_driver_name, ctx->x11_screen); - if (driver_name) - *driver_name = nvidia_driver_name; - } - return vaStatus; + result = VA_NVCTRLQueryDirectRenderingCapable(ctx->x11_dpy, ctx->x11_screen, + &direct_capable); + if (!result || !direct_capable) + return VA_STATUS_ERROR_UNKNOWN; + + result = VA_NVCTRLGetClientDriverName(ctx->x11_dpy, ctx->x11_screen, + &driver_major, &driver_minor, + &driver_patch, driver_name); + if (!result) + return VA_STATUS_ERROR_UNKNOWN; + + return VA_STATUS_SUCCESS; } static VAStatus va_DisplayContextGetDriverName ( |