g3dvl: Use block and stride instead of cpp and pitch.
authorYounes Manton <younes.m@gmail.com>
Mon, 30 Jun 2008 23:26:22 +0000 (19:26 -0400)
committerYounes Manton <younes.m@gmail.com>
Mon, 30 Jun 2008 23:26:22 +0000 (19:26 -0400)
src/gallium/state_trackers/g3dvl/vl_context.c
src/gallium/state_trackers/g3dvl/vl_shader_build.c
src/gallium/state_trackers/g3dvl/vl_surface.c
src/gallium/winsys/g3dvl/xsp_winsys.c
src/libXvMC/Makefile

index 88da47c06a6631b27f377214c64eee37888f93ed..bd8743dc9a5dbf3fca93dfcbe2eeedad3fe2797c 100644 (file)
@@ -1407,7 +1407,7 @@ static int vlInitMC(struct VL_CONTEXT *context)
        template.height[0] = 8 * 4;
        template.depth[0] = 1;
        template.compressed = 0;
-       template.cpp = 2;
+       pf_get_block(template.format, &template.block);
        
        context->states.mc.textures[0] = pipe->screen->texture_create(pipe->screen, &template);
        
index fd9de7dab8c9de96395222e82542e96b54439f3b..365ad697257e52bb17c622370ae93ef8b1450939 100644 (file)
@@ -11,8 +11,8 @@ struct tgsi_full_declaration vl_decl_input(unsigned int name, unsigned int index
        decl.Declaration.Semantic = 1;
        decl.Semantic.SemanticName = name;
        decl.Semantic.SemanticIndex = index;
-       decl.u.DeclarationRange.First = first;
-       decl.u.DeclarationRange.Last = last;
+       decl.DeclarationRange.First = first;
+       decl.DeclarationRange.Last = last;
        
        return decl;
 }
@@ -39,10 +39,9 @@ struct tgsi_full_declaration vl_decl_interpolated_input
        decl.Declaration.Semantic = 1;
        decl.Semantic.SemanticName = name;
        decl.Semantic.SemanticIndex = index;
-       decl.Declaration.Interpolate = 1;
-       decl.Interpolation.Interpolate = interpolation;
-       decl.u.DeclarationRange.First = first;
-       decl.u.DeclarationRange.Last = last;
+       decl.Declaration.Interpolate = interpolation;;
+       decl.DeclarationRange.First = first;
+       decl.DeclarationRange.Last = last;
        
        return decl;
 }
@@ -55,8 +54,8 @@ struct tgsi_full_declaration vl_decl_constants(unsigned int name, unsigned int i
        decl.Declaration.Semantic = 1;
        decl.Semantic.SemanticName = name;
        decl.Semantic.SemanticIndex = index;
-       decl.u.DeclarationRange.First = first;
-       decl.u.DeclarationRange.Last = last;
+       decl.DeclarationRange.First = first;
+       decl.DeclarationRange.Last = last;
        
        return decl;
 }
@@ -69,8 +68,8 @@ struct tgsi_full_declaration vl_decl_output(unsigned int name, unsigned int inde
        decl.Declaration.Semantic = 1;
        decl.Semantic.SemanticName = name;
        decl.Semantic.SemanticIndex = index;
-       decl.u.DeclarationRange.First = first;
-       decl.u.DeclarationRange.Last = last;
+       decl.DeclarationRange.First = first;
+       decl.DeclarationRange.Last = last;
        
        return decl;
 }
@@ -81,8 +80,8 @@ struct tgsi_full_declaration vl_decl_samplers(unsigned int first, unsigned int l
 
        decl = tgsi_default_full_declaration();
        decl.Declaration.File = TGSI_FILE_SAMPLER;
-       decl.u.DeclarationRange.First = first;
-       decl.u.DeclarationRange.Last = last;
+       decl.DeclarationRange.First = first;
+       decl.DeclarationRange.Last = last;
        
        return decl;
 }
index d2220d7abf520f275fa92e07977776e7b39555fd..68313cc7505932f08265639c0c417e2422564499 100644 (file)
@@ -98,6 +98,7 @@ static int vlGrabBlocks
 {
        struct pipe_surface     *tex_surface;
        short                   *texels;
+       unsigned int            tex_pitch;
        unsigned int            tb, sb = 0;
        
        assert(context);
@@ -111,6 +112,7 @@ static int vlGrabBlocks
        );
        
        texels = pipe_surface_map(tex_surface, PIPE_BUFFER_USAGE_CPU_WRITE);
+       tex_pitch = tex_surface->stride / tex_surface->block.size;
        
        for (tb = 0; tb < 4; ++tb)
        {
@@ -121,35 +123,35 @@ static int vlGrabBlocks
                                        vlGrabFrameCodedFullBlock
                                        (
                                                blocks + sb * VL_BLOCK_WIDTH * VL_BLOCK_HEIGHT,
-                                               texels + tb * tex_surface->pitch * VL_BLOCK_HEIGHT,
-                                               tex_surface->pitch
+                                               texels + tb * tex_pitch * VL_BLOCK_HEIGHT,
+                                               tex_pitch
                                        );
                                else
                                        vlGrabFrameCodedDiffBlock
                                        (
                                                blocks + sb * VL_BLOCK_WIDTH * VL_BLOCK_HEIGHT,
-                                               texels + tb * tex_surface->pitch * VL_BLOCK_HEIGHT,
-                                               tex_surface->pitch
+                                               texels + tb * tex_pitch * VL_BLOCK_HEIGHT,
+                                               tex_pitch
                                        );
                        else
                                if (sample_type == VL_FULL_SAMPLE)
                                        vlGrabFieldCodedFullBlock
                                        (
                                                blocks + sb * VL_BLOCK_WIDTH * VL_BLOCK_HEIGHT,
-                                               texels + (tb % 2) * tex_surface->pitch * VL_BLOCK_HEIGHT + (tb / 2) * tex_surface->pitch,
-                                               tex_surface->pitch
+                                               texels + (tb % 2) * tex_pitch * VL_BLOCK_HEIGHT + (tb / 2) * tex_pitch,
+                                               tex_pitch
                                        );
                                else
                                        vlGrabFieldCodedDiffBlock
                                        (
                                                blocks + sb * VL_BLOCK_WIDTH * VL_BLOCK_HEIGHT,
-                                               texels + (tb % 2) * tex_surface->pitch * VL_BLOCK_HEIGHT + (tb / 2) * tex_surface->pitch,
-                                               tex_surface->pitch
+                                               texels + (tb % 2) * tex_pitch * VL_BLOCK_HEIGHT + (tb / 2) * tex_pitch,
+                                               tex_pitch
                                        );
                        ++sb;
                }
                else
-                       vlGrabNoBlock(texels + tb * tex_surface->pitch * VL_BLOCK_HEIGHT, tex_surface->pitch);
+                       vlGrabNoBlock(texels + tb * tex_pitch * VL_BLOCK_HEIGHT, tex_pitch);
        }
        
        pipe_surface_unmap(tex_surface);
@@ -165,6 +167,7 @@ static int vlGrabBlocks
                        );
        
                texels = pipe_surface_map(tex_surface, PIPE_BUFFER_USAGE_CPU_WRITE);
+               tex_pitch = tex_surface->stride / tex_surface->block.size;
                
                if ((coded_block_pattern >> (1 - tb)) & 1)
                {                       
@@ -173,20 +176,20 @@ static int vlGrabBlocks
                                (
                                        blocks + sb * VL_BLOCK_WIDTH * VL_BLOCK_HEIGHT,
                                        texels,
-                                       tex_surface->pitch
+                                       tex_pitch
                                );
                        else
                                vlGrabFrameCodedDiffBlock
                                (
                                        blocks + sb * VL_BLOCK_WIDTH * VL_BLOCK_HEIGHT,
                                        texels,
-                                       tex_surface->pitch
+                                       tex_pitch
                                );
                        
                        ++sb;
                }
                else
-                       vlGrabNoBlock(texels, tex_surface->pitch);
+                       vlGrabNoBlock(texels, tex_pitch);
                
                pipe_surface_unmap(tex_surface);
        }
@@ -223,7 +226,7 @@ int vlCreateSurface(struct VL_CONTEXT *context, struct VL_SURFACE **surface)
        template.height[0] = sfc->height;
        template.depth[0] = 1;
        template.compressed = 0;
-       template.cpp = 4;
+       pf_get_block(template.format, &template.block);
        template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_RENDER_TARGET;
        
        sfc->texture = pipe->screen->texture_create(pipe->screen, &template);
index eb4c9085d6d003f9073cde63814d2776f92b9aa5..d04c4be580ffbb08447b6bc236e8f8c240b75566 100644 (file)
@@ -101,6 +101,12 @@ static struct pipe_surface* xsp_surface_alloc(struct pipe_winsys *pws)
        return surface;
 }
 
+/* Borrowed from Mesa's xm_winsys */
+static unsigned int round_up(unsigned n, unsigned multiple)
+{
+   return (n + multiple - 1) & ~(multiple - 1);
+}
+
 static int xsp_surface_alloc_storage
 (
        struct pipe_winsys *pws,
@@ -120,10 +126,13 @@ static int xsp_surface_alloc_storage
        surface->width = width;
        surface->height = height;
        surface->format = format;
-       surface->cpp = pf_get_size(format);
-       surface->pitch = width;
+       pf_get_block(format, &surface->block);
+       surface->nblocksx = pf_get_nblocksx(&surface->block, width);
+       surface->nblocksy = pf_get_nblocksy(&surface->block, height);
+       surface->stride = round_up(surface->nblocksx * surface->block.size, ALIGNMENT);
        surface->usage = flags;
-       surface->buffer = pws->buffer_create(pws, ALIGNMENT, PIPE_BUFFER_USAGE_PIXEL, surface->pitch * surface->cpp * height);
+       /* XXX: Need to consider block dims? See xm_winsys.c */
+       surface->buffer = pws->buffer_create(pws, ALIGNMENT, PIPE_BUFFER_USAGE_PIXEL, surface->stride * height);
        
        return 0;
 }
index b2f41e176d4c4bee249a6a5cdd31bb3e131f8ec6..4985ecd3e9df07ad6a8484049e0e6eee3927db77 100644 (file)
@@ -17,7 +17,7 @@ LDFLAGS       += -L${GALLIUMDIR}/state_trackers/g3dvl         \
           -L${GALLIUMDIR}/auxiliary/cso_cache          \
           -L${GALLIUMDIR}/auxiliary/util               \
           -L${GALLIUMDIR}/auxiliary/rtasm
-LIBS   += -lg3dvl -lsoftpipe -ldraw -ltgsi -ltranslate -lrtasm -lcso_cache -lutil
+LIBS   += -lg3dvl -lsoftpipe -ldraw -ltgsi -ltranslate -lrtasm -lcso_cache -lutil -lm
 
 #############################################