g3dvl: Use rotating buffers to avoid waiting for map().
authorYounes Manton <younes.m@gmail.com>
Mon, 18 Aug 2008 04:04:29 +0000 (00:04 -0400)
committerYounes Manton <younes.m@gmail.com>
Mon, 18 Aug 2008 04:04:29 +0000 (00:04 -0400)
src/driclient/src/Makefile
src/gallium/state_trackers/g3dvl/Makefile
src/gallium/state_trackers/g3dvl/vl_data.c [deleted file]
src/gallium/state_trackers/g3dvl/vl_data.h [deleted file]
src/gallium/state_trackers/g3dvl/vl_r16snorm_mc.c
src/gallium/winsys/g3dvl/nouveau/Makefile
src/libXvMC/Makefile

index 89ffb84477f4f90cc4723a33e971ef44afc47d8f..5d913ad5fa54e2735c5e67b4a959bd4e3e783c37 100644 (file)
@@ -2,7 +2,7 @@ TARGET          = libdriclient.a
 OBJECTS                = driclient.o XF86dri.o
 DRMDIR         ?= /usr
 
-CFLAGS         += -g -Wall -fPIC -Werror -I../include -I${DRMDIR}/include -I${DRMDIR}/include/drm
+CFLAGS         += -g -Wall -fPIC -I../include -I${DRMDIR}/include -I${DRMDIR}/include/drm
 
 #############################################
 
index 9995c554ab88b186375a0be77313704cab4abf78..bd77c62bc58cc1ce73977d3ccd43e30644cef3e8 100644 (file)
@@ -1,9 +1,9 @@
 TARGET         = libg3dvl.a
-OBJECTS                = vl_display.o vl_screen.o vl_context.o vl_surface.o vl_data.o vl_shader_build.o vl_util.o vl_basic_csc.o \
+OBJECTS                = vl_display.o vl_screen.o vl_context.o vl_surface.o vl_shader_build.o vl_util.o vl_basic_csc.o \
                  vl_r16snorm_mc.o
 GALLIUMDIR     = ../..
 
-CFLAGS         += -g -Wall -fPIC -Werror -I${GALLIUMDIR}/include -I${GALLIUMDIR}/auxiliary -I${GALLIUMDIR}/winsys/g3dvl
+CFLAGS         += -g -Wall -fPIC -I${GALLIUMDIR}/include -I${GALLIUMDIR}/auxiliary -I${GALLIUMDIR}/winsys/g3dvl
 
 #############################################
 
diff --git a/src/gallium/state_trackers/g3dvl/vl_data.c b/src/gallium/state_trackers/g3dvl/vl_data.c
deleted file mode 100644 (file)
index f2476db..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-#include "vl_data.h"
-
-/*
- * Represents 8 triangles (4 quads, 1 per block) in noormalized coords
- * that render a macroblock.
- * Need to be scaled to cover mbW*mbH macroblock pixels and translated into
- * position on target surface.
- */
-const struct vlVertex2f macroblock_verts[24] =
-{
-       {0.0f, 0.0f}, {0.0f, 0.5f}, {0.5f, 0.0f},
-       {0.5f, 0.0f}, {0.0f, 0.5f}, {0.5f, 0.5f},
-
-       {0.5f, 0.0f}, {0.5f, 0.5f}, {1.0f, 0.0f},
-       {1.0f, 0.0f}, {0.5f, 0.5f}, {1.0f, 0.5f},
-
-       {0.0f, 0.5f}, {0.0f, 1.0f}, {0.5f, 0.5f},
-       {0.5f, 0.5f}, {0.0f, 1.0f}, {0.5f, 1.0f},
-
-       {0.5f, 0.5f}, {0.5f, 1.0f}, {1.0f, 0.5f},
-       {1.0f, 0.5f}, {0.5f, 1.0f}, {1.0f, 1.0f}
-};
-
-/*
- * Represents texcoords for the above for rendering 4 luma blocks arranged
- * in a bW*(bH*4) texture. First luma block located at 0,0->bW,bH; second at
- * 0,bH->bW,2bH; third at 0,2bH->bW,3bH; fourth at 0,3bH->bW,4bH.
- */
-const struct vlVertex2f macroblock_luma_texcoords[24] =
-{
-       {0.0f, 0.0f}, {0.0f, 0.25f}, {1.0f, 0.0f},
-       {1.0f, 0.0f}, {0.0f, 0.25f}, {1.0f, 0.25f},
-
-       {0.0f, 0.25f}, {0.0f, 0.5f}, {1.0f, 0.25f},
-       {1.0f, 0.25f}, {0.0f, 0.5f}, {1.0f, 0.5f},
-
-       {0.0f, 0.5f}, {0.0f, 0.75f}, {1.0f, 0.5f},
-       {1.0f, 0.5f}, {0.0f, 0.75f}, {1.0f, 0.75f},
-
-       {0.0f, 0.75f}, {0.0f, 1.0f}, {1.0f, 0.75f},
-       {1.0f, 0.75f}, {0.0f, 1.0f}, {1.0f, 1.0f}
-};
-
-/*
- * Represents texcoords for the above for rendering 1 chroma block.
- * Straight forward 0,0->1,1 mapping so we can reuse the MB pos vectors.
- */
-const struct vlVertex2f *macroblock_chroma_420_texcoords = macroblock_verts;
-
-/*
- * Represents texcoords for the above for rendering 2 chroma blocks arranged
- * in a bW*(bH*2) texture. First chroma block located at 0,0->bW,bH; second at
- * 0,bH->bW,2bH. We can render this with 0,0->1,1 mapping.
- * Straight forward 0,0->1,1 mapping so we can reuse MB pos vectors.
- */
-const struct vlVertex2f *macroblock_chroma_422_texcoords = macroblock_verts;
-
-/*
- * Represents texcoords for the above for rendering 4 chroma blocks.
- * Same case as 4 luma blocks.
- */
-const struct vlVertex2f *macroblock_chroma_444_texcoords = macroblock_luma_texcoords;
-
-/*
- * Used when rendering P and B macroblocks, multiplier is applied to the A channel,
- * which is then added to the L channel, then the bias is subtracted from that to
- * get back the differential. The differential is then added to the samples from the
- * reference surface(s).
- */
-#if 0
-const struct VL_MC_FS_CONSTS vl_mc_fs_consts =
-{
-       {32767.0f / 255.0f, 32767.0f / 255.0f, 32767.0f / 255.0f, 0.0f},
-       {0.5f, 2.0f, 0.0f, 0.0f}
-};
-#endif
diff --git a/src/gallium/state_trackers/g3dvl/vl_data.h b/src/gallium/state_trackers/g3dvl/vl_data.h
deleted file mode 100644 (file)
index f0de2e9..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef vl_data_h
-#define vl_data_h
-
-#include "vl_types.h"
-
-/* TODO: Needs to be rolled into the appropriate stage */
-
-extern const struct vlVertex2f macroblock_verts[24];
-extern const struct vlVertex2f macroblock_luma_texcoords[24];
-extern const struct vlVertex2f *macroblock_chroma_420_texcoords;
-extern const struct vlVertex2f *macroblock_chroma_422_texcoords;
-extern const struct vlVertex2f *macroblock_chroma_444_texcoords;
-
-extern const struct vlVertex2f surface_verts[4];
-extern const struct vlVertex2f *surface_texcoords;
-
-/*
-extern const struct VL_MC_FS_CONSTS vl_mc_fs_consts;
-
-extern const struct VL_CSC_FS_CONSTS vl_csc_fs_consts_identity;
-extern const struct VL_CSC_FS_CONSTS vl_csc_fs_consts_601;
-extern const struct VL_CSC_FS_CONSTS vl_csc_fs_consts_601_full;
-extern const struct VL_CSC_FS_CONSTS vl_csc_fs_consts_709;
-extern const struct VL_CSC_FS_CONSTS vl_csc_fs_consts_709_full;
-*/
-
-#endif
index 4fae2244310964cd1e86163f6bee3584d18b3bac..80b09a6d1d04c976e731833729fb5a941d62fb7a 100644 (file)
@@ -15,6 +15,8 @@
 #include "vl_types.h"
 #include "vl_defs.h"
 
+#define NUM_BUFS 4     /* Number of rotating buffers to use */
+
 struct vlVertexShaderConsts
 {
        /*struct vlVertex4f scale;
@@ -41,12 +43,13 @@ struct vlR16SnormMC
 
        unsigned int                            video_width, video_height;
        enum vlFormat                           video_format;
+       unsigned int                            cur_buf;
 
        struct pipe_context                     *pipe;
        struct pipe_viewport_state              viewport;
        struct pipe_framebuffer_state           render_target;
        struct pipe_sampler_state               *samplers[5];
-       struct pipe_texture                     *textures[5];
+       struct pipe_texture                     *textures[NUM_BUFS][5];
        void                                    *i_vs, *p_vs[2], *b_vs[2];
        void                                    *i_fs, *p_fs[2], *b_fs[2];
        struct pipe_vertex_buffer               vertex_bufs[3];
@@ -230,7 +233,7 @@ static int vlGrabBlocks
        tex_surface = mc->pipe->screen->get_tex_surface
        (
                mc->pipe->screen,
-               mc->textures[0],
+               mc->textures[mc->cur_buf % NUM_BUFS][0],
                0, 0, 0, PIPE_BUFFER_USAGE_CPU_WRITE
        );
 
@@ -276,7 +279,7 @@ static int vlGrabBlocks
                tex_surface = mc->pipe->screen->get_tex_surface
                (
                        mc->pipe->screen,
-                       mc->textures[tb + 1],
+                       mc->textures[mc->cur_buf % NUM_BUFS][tb + 1],
                        0, 0, 0, PIPE_BUFFER_USAGE_CPU_WRITE
                );
 
@@ -361,12 +364,14 @@ int vlRenderIMacroBlock
                0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE
        );
        pipe->set_framebuffer_state(pipe, &mc->render_target);
-       pipe->set_sampler_textures(pipe, 3, mc->textures);
+       pipe->set_sampler_textures(pipe, 3, mc->textures[mc->cur_buf % NUM_BUFS]);
        pipe->bind_sampler_states(pipe, 3, (void**)mc->samplers);
        pipe->bind_vs_state(pipe, mc->i_vs);
        pipe->bind_fs_state(pipe, mc->i_fs);
 
        pipe->draw_arrays(pipe, PIPE_PRIM_TRIANGLES, 0, 24);
+       
+       mc->cur_buf++;
 
        return 0;
 }
@@ -458,11 +463,13 @@ int vlRenderPMacroBlock
        );
        pipe->set_framebuffer_state(pipe, &mc->render_target);
 
-       mc->textures[3] = ref_surface->texture;
-       pipe->set_sampler_textures(pipe, 4, mc->textures);
+       mc->textures[mc->cur_buf % NUM_BUFS][3] = ref_surface->texture;
+       pipe->set_sampler_textures(pipe, 4, mc->textures[mc->cur_buf % NUM_BUFS]);
        pipe->bind_sampler_states(pipe, 4, (void**)mc->samplers);
 
        pipe->draw_arrays(pipe, PIPE_PRIM_TRIANGLES, 0, 24);
+       
+       mc->cur_buf++;
 
        return 0;
 }
@@ -567,12 +574,14 @@ int vlRenderBMacroBlock
        );
        pipe->set_framebuffer_state(pipe, &mc->render_target);
 
-       mc->textures[3] = past_surface->texture;
-       mc->textures[4] = future_surface->texture;
-       pipe->set_sampler_textures(pipe, 5, mc->textures);
+       mc->textures[mc->cur_buf % NUM_BUFS][3] = past_surface->texture;
+       mc->textures[mc->cur_buf % NUM_BUFS][4] = future_surface->texture;
+       pipe->set_sampler_textures(pipe, 5, mc->textures[mc->cur_buf % NUM_BUFS]);
        pipe->bind_sampler_states(pipe, 5, (void**)mc->samplers);
 
        pipe->draw_arrays(pipe, PIPE_PRIM_TRIANGLES, 0, 24);
+       
+       mc->cur_buf++;
 
        return 0;
 }
@@ -724,8 +733,12 @@ int vlDestroy
                pipe->winsys->buffer_destroy(pipe->winsys, mc->vertex_bufs[i].buffer);
 
        /* Textures 3 & 4 are not created directly, no need to release them here */
-       for (i = 0; i < 3; ++i)
-               pipe_texture_release(&mc->textures[i]);
+       for (i = 0; i < NUM_BUFS; ++i)
+       {
+               pipe_texture_release(&mc->textures[i][0]);
+               pipe_texture_release(&mc->textures[i][1]);
+               pipe_texture_release(&mc->textures[i][2]);
+       }
 
        pipe->delete_vs_state(pipe, mc->i_vs);
        pipe->delete_fs_state(pipe, mc->i_fs);
@@ -2252,7 +2265,8 @@ static int vlInit
        template.compressed = 0;
        pf_get_block(template.format, &template.block);
 
-       mc->textures[0] = pipe->screen->texture_create(pipe->screen, &template);
+       for (i = 0; i < NUM_BUFS; ++i)
+               mc->textures[i][0] = pipe->screen->texture_create(pipe->screen, &template);
 
        if (mc->video_format == vlFormatYCbCr420)
                template.height[0] = 8;
@@ -2263,8 +2277,11 @@ static int vlInit
        else
                assert(0);
 
-       mc->textures[1] = pipe->screen->texture_create(pipe->screen, &template);
-       mc->textures[2] = pipe->screen->texture_create(pipe->screen, &template);
+       for (i = 0; i < NUM_BUFS; ++i)
+       {
+               mc->textures[i][1] = pipe->screen->texture_create(pipe->screen, &template);
+               mc->textures[i][2] = pipe->screen->texture_create(pipe->screen, &template);
+       }
 
        /* textures[3] & textures[4] are assigned from vlSurfaces for P and B macroblocks at render time */
 
@@ -2306,6 +2323,7 @@ int vlCreateR16SNormMC
        mc->pipe = pipe;
        mc->video_width = video_width;
        mc->video_height = video_height;
+       mc->cur_buf = 0;
 
        vlInit(mc);
 
index 2861bd7db4fd0ccda3d8823905aea3cce3e551d5..7fa29d2f5fb844335f47d811c533f6adaad25806 100644 (file)
@@ -9,7 +9,7 @@ OBJECTS         = nouveau_bo.o nouveau_fence.o nouveau_swapbuffers.o nouveau_channel.o
                  nouveau_pushbuf.o nouveau_resource.o nouveau_screen.o nv04_surface.o          \
                  nv50_surface.o #nouveau_winsys_softpipe.o
 
-CFLAGS         += -g -Wall -Werror -fPIC               \
+CFLAGS         += -g -Wall -fPIC                       \
                   -I${GALLIUMDIR}/include              \
                   -I${GALLIUMDIR}/winsys/g3dvl         \
                   -I${DRMDIR}/include                  \
index c154e17dc353577678f8b430c7d924a3f42d2632..b72bb16efbffc66801506ba566670a9ebdfc49aa 100644 (file)
@@ -8,7 +8,7 @@ ifeq (${DRIVER}, softpipe)
 OBJECTS         += ${GALLIUMDIR}/winsys/g3dvl/xsp_winsys.o
 endif
 
-CFLAGS += -g -fPIC -Wall -Werror                       \
+CFLAGS += -g -fPIC -Wall                               \
           -I${GALLIUMDIR}/state_trackers/g3dvl         \
           -I${GALLIUMDIR}/winsys/g3dvl                 \
           -I${GALLIUMDIR}/include                      \