[g3dvl] rename get_param to get_video_param and move into screen object
authorChristian König <deathsimple@vodafone.de>
Thu, 7 Jul 2011 20:51:45 +0000 (22:51 +0200)
committerChristian König <deathsimple@vodafone.de>
Thu, 7 Jul 2011 20:51:45 +0000 (22:51 +0200)
src/gallium/auxiliary/vl/vl_context.c
src/gallium/auxiliary/vl/vl_context.h
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r300/r300_video_context.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_video_context.c
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/include/pipe/p_defines.h
src/gallium/include/pipe/p_screen.h
src/gallium/include/pipe/p_video_context.h
src/gallium/state_trackers/xorg/xvmc/subpicture.c

index e3aa49d2856fe073b647335e4f4584ecd40e1753..3a90a247bd81041b7fb940b67f8e8eb9ec259f4e 100644 (file)
@@ -47,20 +47,6 @@ vl_context_destroy(struct pipe_video_context *context)
    FREE(ctx);
 }
 
-static int
-vl_context_get_param(struct pipe_video_context *context, int param)
-{
-   struct vl_context *ctx = (struct vl_context*)context;
-
-   assert(context);
-
-   if (param == PIPE_CAP_NPOT_TEXTURES)
-      return !ctx->pot_buffers;
-
-   debug_printf("vl_context: Unknown PIPE_CAP %d\n", param);
-   return 0;
-}
-
 static boolean
 vl_context_is_format_supported(struct pipe_video_context *context,
                                enum pipe_format format,
@@ -192,12 +178,15 @@ vl_context_create_decoder(struct pipe_video_context *context,
 {
    struct vl_context *ctx = (struct vl_context*)context;
    unsigned buffer_width, buffer_height;
+   bool pot_buffers;
 
    assert(context);
    assert(width > 0 && height > 0);
+   
+   pot_buffers = !ctx->base.screen->get_video_param(ctx->base.screen, profile, PIPE_VIDEO_CAP_NPOT_TEXTURES);
 
-   buffer_width = ctx->pot_buffers ? util_next_power_of_two(width) : align(width, MACROBLOCK_WIDTH);
-   buffer_height = ctx->pot_buffers ? util_next_power_of_two(height) : align(height, MACROBLOCK_HEIGHT);
+   buffer_width = pot_buffers ? util_next_power_of_two(width) : align(width, MACROBLOCK_WIDTH);
+   buffer_height = pot_buffers ? util_next_power_of_two(height) : align(height, MACROBLOCK_HEIGHT);
 
    switch (u_reduce_video_profile(profile)) {
       case PIPE_VIDEO_CODEC_MPEG12:
@@ -219,16 +208,24 @@ vl_context_create_buffer(struct pipe_video_context *context,
    const enum pipe_format *resource_formats;
    struct pipe_video_buffer *result;
    unsigned buffer_width, buffer_height;
+   bool pot_buffers;
 
    assert(context);
    assert(width > 0 && height > 0);
 
+   pot_buffers = !ctx->base.screen->get_video_param
+   (
+      ctx->base.screen,
+      PIPE_VIDEO_PROFILE_UNKNOWN,
+      PIPE_VIDEO_CAP_NPOT_TEXTURES
+   );
+
    resource_formats = vl_video_buffer_formats(ctx->pipe, buffer_format);
    if (!resource_formats)
       return NULL;
 
-   buffer_width = ctx->pot_buffers ? util_next_power_of_two(width) : align(width, MACROBLOCK_WIDTH);
-   buffer_height = ctx->pot_buffers ? util_next_power_of_two(height) : align(height, MACROBLOCK_HEIGHT);
+   buffer_width = pot_buffers ? util_next_power_of_two(width) : align(width, MACROBLOCK_WIDTH);
+   buffer_height = pot_buffers ? util_next_power_of_two(height) : align(height, MACROBLOCK_HEIGHT);
 
    result = vl_video_buffer_init(context, ctx->pipe,
                                  buffer_width, buffer_height, 1,
@@ -252,7 +249,7 @@ vl_context_create_compositor(struct pipe_video_context *context)
 }
 
 struct pipe_video_context *
-vl_create_context(struct pipe_context *pipe, bool pot_buffers)
+vl_create_context(struct pipe_context *pipe)
 {
    struct vl_context *ctx;
 
@@ -264,7 +261,6 @@ vl_create_context(struct pipe_context *pipe, bool pot_buffers)
    ctx->base.screen = pipe->screen;
 
    ctx->base.destroy = vl_context_destroy;
-   ctx->base.get_param = vl_context_get_param;
    ctx->base.is_format_supported = vl_context_is_format_supported;
    ctx->base.create_surface = vl_context_create_surface;
    ctx->base.create_sampler_view = vl_context_create_sampler_view;
@@ -275,7 +271,6 @@ vl_create_context(struct pipe_context *pipe, bool pot_buffers)
    ctx->base.create_compositor = vl_context_create_compositor;
 
    ctx->pipe = pipe;
-   ctx->pot_buffers = pot_buffers;
 
    return &ctx->base;
 }
index 9f12a0df9259dd6cd475725b501196433af2303a..4fbe2651d8998b28d2abeb14d70f4e7076b78dc1 100644 (file)
@@ -38,12 +38,11 @@ struct vl_context
 {
    struct pipe_video_context base;
    struct pipe_context *pipe;
-   bool pot_buffers;
 };
 
 /* drivers can call this function in their pipe_video_context constructors and pass it
    an accelerated pipe_context along with suitable buffering modes, etc */
 struct pipe_video_context *
-vl_create_context(struct pipe_context *pipe, bool pot_buffers);
+vl_create_context(struct pipe_context *pipe);
 
 #endif /* vl_context_h */
index 05af2148b38b5576eb455d8466d5cd429df7899c..a440ecb8c396116492befe3dace3723714b43bf0 100644 (file)
@@ -303,6 +303,18 @@ static float r300_get_paramf(struct pipe_screen* pscreen, enum pipe_cap param)
     }
 }
 
+static int r300_get_video_param(struct pipe_screen *screen,
+                               enum pipe_video_profile profile,
+                               enum pipe_video_cap param)
+{
+       switch (param) {
+       case PIPE_VIDEO_CAP_NPOT_TEXTURES:
+               return 0;
+       default:
+               return 0;
+       }
+}
+
 static boolean r300_is_format_supported(struct pipe_screen* screen,
                                         enum pipe_format format,
                                         enum pipe_texture_target target,
@@ -508,6 +520,7 @@ struct pipe_screen* r300_screen_create(struct radeon_winsys *rws)
     r300screen->screen.get_param = r300_get_param;
     r300screen->screen.get_shader_param = r300_get_shader_param;
     r300screen->screen.get_paramf = r300_get_paramf;
+    r300screen->screen.get_video_param = r300_get_video_param;
     r300screen->screen.is_format_supported = r300_is_format_supported;
     r300screen->screen.context_create = r300_create_context;
     r300screen->screen.video_context_create = r300_video_create;
index 1d5bfefb9dd88b6623ad853aa0d6adebec8e5719..697e45a57459e992366f54e73abca7b98f16df88 100644 (file)
@@ -34,5 +34,5 @@ r300_video_create(struct pipe_screen *screen, void *priv)
    if (!pipe)
       return NULL;
 
-   return vl_create_context(pipe, false);
+   return vl_create_context(pipe);
 }
index 049a4daae665cd562b6605dbef9d557b4e67ccdb..a25b6d0ff9699ba948998ea687fd0509ec46dd11 100644 (file)
@@ -507,6 +507,18 @@ static int r600_get_shader_param(struct pipe_screen* pscreen, unsigned shader, e
        }
 }
 
+static int r600_get_video_param(struct pipe_screen *screen,
+                               enum pipe_video_profile profile,
+                               enum pipe_video_cap param)
+{
+       switch (param) {
+       case PIPE_VIDEO_CAP_NPOT_TEXTURES:
+               return 1;
+       default:
+               return 0;
+       }
+}
+
 static boolean r600_is_format_supported(struct pipe_screen* screen,
                                        enum pipe_format format,
                                        enum pipe_texture_target target,
@@ -653,6 +665,7 @@ struct pipe_screen *r600_screen_create(struct radeon *radeon)
        rscreen->screen.get_param = r600_get_param;
        rscreen->screen.get_shader_param = r600_get_shader_param;
        rscreen->screen.get_paramf = r600_get_paramf;
+       rscreen->screen.get_video_param = r600_get_video_param;
        rscreen->screen.is_format_supported = r600_is_format_supported;
        rscreen->screen.context_create = r600_create_context;
        rscreen->screen.video_context_create = r600_video_create;
index a0ab3475fde5919376e027c4b7ee04e939811027..5f0d5f5baecadb66a0381cea03cd72320cfdecc2 100644 (file)
@@ -40,5 +40,5 @@ r600_video_create(struct pipe_screen *screen, void *priv)
    if (!pipe)
       return NULL;
 
-   return vl_create_context(pipe, false);
+   return vl_create_context(pipe);
 }
index ac2e65b988e609266e56c2b4c56309baa9221a28..f0467e9148de98087b926e57025fb68c9d5e1459 100644 (file)
@@ -171,6 +171,18 @@ softpipe_get_paramf(struct pipe_screen *screen, enum pipe_cap param)
    }
 }
 
+static int
+softpipe_get_video_param(struct pipe_screen *screen,
+                         enum pipe_video_profile profile,
+                         enum pipe_video_cap param)
+{
+   switch (param) {
+   case PIPE_VIDEO_CAP_NPOT_TEXTURES:
+      return 0;
+   default:
+      return 0;
+   }
+}
 
 /**
  * Query format support for creating a texture, drawing surface, etc.
@@ -299,7 +311,7 @@ sp_video_create(struct pipe_screen *screen, void *priv)
       return NULL;
 
    /* TODO: Use slice buffering for softpipe when implemented, no advantage to buffering an entire picture with softpipe */
-   return vl_create_context(pipe, true);
+   return vl_create_context(pipe);
 }
 
 /**
@@ -324,6 +336,7 @@ softpipe_create_screen(struct sw_winsys *winsys)
    screen->base.get_param = softpipe_get_param;
    screen->base.get_shader_param = softpipe_get_shader_param;
    screen->base.get_paramf = softpipe_get_paramf;
+   screen->base.get_video_param = softpipe_get_video_param;
    screen->base.is_format_supported = softpipe_is_format_supported;
    screen->base.context_create = softpipe_create_context;
    screen->base.flush_frontbuffer = softpipe_flush_frontbuffer;
index 6c6641588d305c6875335f0fb944c524ef12b8b2..d8b1a9e171f2296ad531c032c09f7d554b4da747 100644 (file)
@@ -493,6 +493,11 @@ enum pipe_shader_cap
    PIPE_SHADER_CAP_SUBROUTINES = 16, /* BGNSUB, ENDSUB, CAL, RET */
 };
 
+/* Video caps, can be different for each codec/profile */
+enum pipe_video_cap
+{
+   PIPE_VIDEO_CAP_NPOT_TEXTURES = 0,
+};
 
 enum pipe_video_codec
 {
index 4f95fa1b2e12ad99af4f282783c64c89bbc51cac..2fa469bbea76a85c27b166526b48be71aad57e74 100644 (file)
@@ -92,6 +92,12 @@ struct pipe_screen {
     */
    int (*get_shader_param)( struct pipe_screen *, unsigned shader, enum pipe_shader_cap param );
 
+   /**
+    * Query an integer-valued capability/parameter/limit for a codec/profile
+    * \param param  one of PIPE_VIDEO_CAP_x
+    */
+   int (*get_video_param)( struct pipe_screen *, enum pipe_video_profile profile, enum pipe_video_cap param );
+
    struct pipe_context * (*context_create)( struct pipe_screen *, void *priv );
 
    struct pipe_video_context * (*video_context_create)( struct pipe_screen *screen, void *priv );
index c9e618b60800eca5ff832074b6a6edf201a4fd00..1fb635f17560ad86b9c27bc36305c617943e5398 100644 (file)
@@ -55,12 +55,6 @@ struct pipe_video_context
     */
    void (*destroy)(struct pipe_video_context *context);
 
-   /**
-    * Query an integer-valued capability/parameter/limit
-    * \param param  one of PIPE_CAP_x
-    */
-   int (*get_param)(struct pipe_video_context *context, int param);
-
    /**
     * Check if the given pipe_format is supported as a video buffer
     */
index 821c87e0dab2706d4be2656fd41c991f6da6de71..b4594ad5e081814fbc74b59bd346e5710bab02ad 100644 (file)
@@ -232,7 +232,9 @@ Status XvMCCreateSubpicture(Display *dpy, XvMCContext *context, XvMCSubpicture *
    tex_templ.target = PIPE_TEXTURE_2D;
    tex_templ.format = XvIDToPipe(xvimage_id);
    tex_templ.last_level = 0;
-   if (vpipe->get_param(vpipe, PIPE_CAP_NPOT_TEXTURES)) {
+   if (vpipe->screen->get_video_param(vpipe->screen,
+                                      PIPE_VIDEO_PROFILE_UNKNOWN,
+                                      PIPE_VIDEO_CAP_NPOT_TEXTURES)) {
       tex_templ.width0 = width;
       tex_templ.height0 = height;
    }