g3dvl: Use block and stride instead of cpp and pitch.

This commit is contained in:
Younes Manton
2008-06-30 19:26:22 -04:00
parent 1c893fd513
commit 9833aec6cb
5 changed files with 41 additions and 30 deletions
@@ -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);
@@ -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;
}
+16 -13
View 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);
+12 -3
View 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;
}
+1 -1
View 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
#############################################