#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
+
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
texTemp.width0 = 1 << MAX_TEXTURE_LEVEL;
texTemp.height0 = 1 << MAX_TEXTURE_LEVEL;
texTemp.depth0 = 1;
- pf_get_block(texTemp.format, &texTemp.block);
+ util_format_get_block(texTemp.format, &texTemp.block);
aaline->texture = screen->texture_create(screen, &texTemp);
if (!aaline->texture)
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
texTemp.width0 = 32;
texTemp.height0 = 32;
texTemp.depth0 = 1;
- pf_get_block(texTemp.format, &texTemp.block);
+ util_format_get_block(texTemp.format, &texTemp.block);
pstip->texture = screen->texture_create(screen, &texTemp);
if (pstip->texture == NULL)
#include "util/u_blit.h"
#include "util/u_draw_quad.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_simple_shaders.h"
texTemp.width0 = srcW;
texTemp.height0 = srcH;
texTemp.depth0 = 1;
- pf_get_block(src->format, &texTemp.block);
+ util_format_get_block(src->format, &texTemp.block);
tex = screen->texture_create(screen, &texTemp);
if (!tex)
/** Block height in pixels */
unsigned height;
- /** Block size in bytes */
+ /** Block size in bits */
unsigned bits;
};
desc->swizzle[1] != UTIL_FORMAT_SWIZZLE_NONE) ? TRUE : FALSE;
}
+/**
+ * Describe pixel format's block.
+ *
+ * @sa http://msdn2.microsoft.com/en-us/library/ms796147.aspx
+ */
+static INLINE void
+util_format_get_block(enum pipe_format format,
+ struct pipe_format_block *block)
+{
+ const struct util_format_description *desc = util_format_description(format);
+
+ assert(format);
+ if (!format) {
+ block->size = 0;
+ block->width = 1;
+ block->height = 1;
+ return;
+ }
+
+ block->size = desc->block.bits / 8;
+ block->width = desc->block.width;
+ block->height = desc->block.height;
+}
+
/*
* Format access functions.
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
+#include "util/u_format.h"
#include "util/u_surface.h"
templ.width0 = width;
templ.height0 = height;
templ.depth0 = 1;
- pf_get_block(format, &templ.block);
+ util_format_get_block(format, &templ.block);
templ.tex_usage = usage;
*textureOut = screen->texture_create(screen, &templ);
#include <assert.h>
#include <pipe/p_context.h>
#include <pipe/p_inlines.h>
+#include <util/u_format.h>
#include <util/u_math.h>
#include <util/u_memory.h>
#include <tgsi/tgsi_parse.h>
template.height0 = r->pot_buffers ?
util_next_power_of_two(r->picture_height) : r->picture_height;
template.depth0 = 1;
- pf_get_block(template.format, &template.block);
+ util_format_get_block(template.format, &template.block);
template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_DYNAMIC;
r->textures.individual.y = r->pipe->screen->texture_create(r->pipe->screen, &template);
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "pipe/internal/p_winsys_screen.h"
+
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
unsigned buffer_size = 0;
- pf_get_block(lpt->base.format, &lpt->base.block);
+ util_format_get_block(lpt->base.format, &lpt->base.block);
for (level = 0; level <= pt->last_level; level++) {
unsigned nblocksx, nblocksy;
{
struct llvmpipe_winsys *winsys = screen->winsys;
- pf_get_block(lpt->base.format, &lpt->base.block);
+ util_format_get_block(lpt->base.format, &lpt->base.block);
lpt->base.nblocksx[0] = pf_get_nblocksx(&lpt->base.block, lpt->base.width0);
lpt->base.nblocksy[0] = pf_get_nblocksy(&lpt->base.block, lpt->base.height0);
#include "pipe/p_screen.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
template.width0 = util_next_power_of_two(width);
template.height0 = util_next_power_of_two(height);
template.depth0 = 1;
- pf_get_block(template.format, &template.block);
+ util_format_get_block(template.format, &template.block);
template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER |
PIPE_TEXTURE_USAGE_RENDER_TARGET;
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
+
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
template.width0 = util_next_power_of_two(width);
template.height0 = util_next_power_of_two(height);
template.depth0 = 1;
- pf_get_block(template.format, &template.block);
+ util_format_get_block(template.format, &template.block);
template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_RENDER_TARGET;
sp_vsfc->tex = screen->texture_create(screen, &template);
unsigned height;
};
-/**
- * Describe pixel format's block.
- *
- * @sa http://msdn2.microsoft.com/en-us/library/ms796147.aspx
- */
-static INLINE void
-pf_get_block(enum pipe_format format, struct pipe_format_block *block)
-{
- switch(format) {
- case PIPE_FORMAT_DXT1_RGBA:
- case PIPE_FORMAT_DXT1_RGB:
- case PIPE_FORMAT_DXT1_SRGBA:
- case PIPE_FORMAT_DXT1_SRGB:
- block->size = 8;
- block->width = 4;
- block->height = 4;
- break;
- case PIPE_FORMAT_DXT3_RGBA:
- case PIPE_FORMAT_DXT5_RGBA:
- case PIPE_FORMAT_DXT3_SRGBA:
- case PIPE_FORMAT_DXT5_SRGBA:
- block->size = 16;
- block->width = 4;
- block->height = 4;
- break;
- case PIPE_FORMAT_YCBCR:
- case PIPE_FORMAT_YCBCR_REV:
- block->size = 4; /* 2*cpp */
- block->width = 2;
- block->height = 1;
- break;
- default:
- block->size = pf_get_size(format);
- block->width = 1;
- block->height = 1;
- break;
- }
-}
-
static INLINE unsigned
pf_get_nblocksx(const struct pipe_format_block *block, unsigned x)
{
#include "state_tracker/st_context.h"
#include "state_tracker/st_cb_fbo.h"
+#include "util/u_format.h"
#include "util/u_memory.h"
#include "util/u_rect.h"
templat.format = format;
templat.width0 = width;
templat.height0 = height;
- pf_get_block(templat.format, &templat.block);
+ util_format_get_block(templat.format, &templat.block);
texture = api->texture_from_shared_handle(api, screen, &templat,
"dri2 buffer", pitch, handle);
#include "state_tracker/drm_api.h"
+#include "util/u_format.h"
#include "util/u_rect.h"
/*
templat.format = PIPE_FORMAT_A8R8G8B8_UNORM;
templat.width0 = w;
templat.height0 = h;
- pf_get_block(templat.format, &templat.block);
+ util_format_get_block(templat.format, &templat.block);
texture = screen->texture_create(dev->screen,
&templat);
struct pipe_texture templat;
memset(&templat, 0, sizeof(templat));
templat.format = format;
- pf_get_block(templat.format, &templat.block);
+ util_format_get_block(templat.format, &templat.block);
templat.width0 = width;
templat.height0 = height;
templat.depth0 = depth;
#include "pipe/p_format.h"
#include "pipe/p_context.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "softpipe/sp_winsys.h"
struct pipe_format_block block;
unsigned nblocksx, nblocksy;
- pf_get_block(format, &block);
+ util_format_get_block(format, &block);
nblocksx = pf_get_nblocksx(&block, width);
nblocksy = pf_get_nblocksy(&block, height);
*stride = round_up(nblocksx * block.size, alignment);
#include "pipe/p_screen.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_format.h"
#include "util/u_memory.h"
templ.width0 = color_data_len;
templ.height0 = 1;
templ.depth0 = 1;
- pf_get_block(PIPE_FORMAT_A8R8G8B8_UNORM, &templ.block);
+ util_format_get_block(PIPE_FORMAT_A8R8G8B8_UNORM, &templ.block);
templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
tex = screen->texture_create(screen, &templ);
#include "pipe/p_screen.h"
#include "pipe/p_inlines.h"
#include "util/u_blit.h"
+#include "util/u_format.h"
#include "util/u_tile.h"
#include "util/u_memory.h"
#include "util/u_math.h"
memset(&pt, 0, sizeof(pt));
pt.target = PIPE_TEXTURE_2D;
pt.format = pformat;
- pf_get_block(pformat, &pt.block);
+ util_format_get_block(pformat, &pt.block);
pt.last_level = 0;
pt.width0 = width;
pt.height0 = height;
#include "pipe/p_context.h"
#include "pipe/p_screen.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_memory.h"
struct vg_mask_layer {
memset(&pt, 0, sizeof(pt));
pt.target = PIPE_TEXTURE_2D;
pt.format = PIPE_FORMAT_A8R8G8B8_UNORM;
- pf_get_block(PIPE_FORMAT_A8R8G8B8_UNORM, &pt.block);
+ util_format_get_block(PIPE_FORMAT_A8R8G8B8_UNORM, &pt.block);
pt.last_level = 0;
pt.width0 = width;
pt.height0 = height;
#include "pipe/p_compiler.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_memory.h"
#include "util/u_math.h"
templ.width0 = 1024;
templ.height0 = 1;
templ.depth0 = 1;
- pf_get_block(PIPE_FORMAT_A8R8G8B8_UNORM, &templ.block);
+ util_format_get_block(PIPE_FORMAT_A8R8G8B8_UNORM, &templ.block);
templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
tex = screen->texture_create(screen, &templ);
#include "pipe/p_shader_tokens.h"
#include "util/u_draw_quad.h"
+#include "util/u_format.h"
#include "util/u_simple_shaders.h"
#include "util/u_memory.h"
#include "util/u_rect.h"
texTemp.width0 = srcW;
texTemp.height0 = srcH;
texTemp.depth0 = 1;
- pf_get_block(src->format, &texTemp.block);
+ util_format_get_block(src->format, &texTemp.block);
tex = screen->texture_create(screen, &texTemp);
if (!tex)
#include "pipe/p_context.h"
#include "pipe/p_inlines.h"
#include "pipe/p_screen.h"
+#include "util/u_format.h"
#include "util/u_memory.h"
#include "util/u_math.h"
}
templ.target = PIPE_TEXTURE_2D;
- pf_get_block(templ.format, &templ.block);
+ util_format_get_block(templ.format, &templ.block);
templ.width0 = width;
templ.height0 = height;
templ.depth0 = 1;
#endif
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_rect.h"
#ifdef HAVE_LIBKMS
templat.format = PIPE_FORMAT_A8R8G8B8_UNORM;
templat.width0 = 64;
templat.height0 = 64;
- pf_get_block(templat.format, &templat.block);
+ util_format_get_block(templat.format, &templat.block);
crtcp->cursor_tex = ms->screen->texture_create(ms->screen,
&templat);
else
template.format = ms->ds_depth_bits_last ?
PIPE_FORMAT_S8Z24_UNORM : PIPE_FORMAT_Z24S8_UNORM;
- pf_get_block(template.format, &template.block);
+ util_format_get_block(template.format, &template.block);
template.width0 = pDraw->width;
template.height0 = pDraw->height;
template.depth0 = 1;
#include "pipe/p_state.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_rect.h"
#include "util/u_math.h"
#include "util/u_debug.h"
memset(&template, 0, sizeof(template));
template.target = PIPE_TEXTURE_2D;
exa_get_pipe_format(depth, &template.format, &bitsPerPixel, &priv->picture_format);
- pf_get_block(template.format, &template.block);
+ util_format_get_block(template.format, &template.block);
if (ROUND_UP_TEXTURES && priv->flags == 0) {
template.width0 = util_next_power_of_two(width);
template.height0 = util_next_power_of_two(height);
memset(&template, 0, sizeof(template));
template.target = PIPE_TEXTURE_2D;
exa_get_pipe_format(depth, &template.format, &bitsPerPixel, &dummy);
- pf_get_block(template.format, &template.block);
+ util_format_get_block(template.format, &template.block);
template.width0 = width;
template.height0 = height;
template.depth0 = 1;
#include "cso_cache/cso_context.h"
#include "util/u_draw_quad.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_rect.h"
templ.width0 = src->width0;
templ.height0 = src->height0;
templ.depth0 = 1;
- pf_get_block(format, &templ.block);
+ util_format_get_block(format, &templ.block);
templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
pt = screen->texture_create(screen, &templ);
#include "pipe/p_screen.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
+
/*XXX get these from pipe's texture limits */
#define IMAGE_MAX_WIDTH 2048
#define IMAGE_MAX_HEIGHT 2048
templ.width0 = width;
templ.height0 = height;
templ.depth0 = 1;
- pf_get_block(PIPE_FORMAT_L8_UNORM, &templ.block);
+ util_format_get_block(PIPE_FORMAT_L8_UNORM, &templ.block);
templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
tex = screen->texture_create(screen, &templ);
template.width0 = width;
template.height0 = height;
template.depth0 = 1;
- pf_get_block(template.format, &template.block);
+ util_format_get_block(template.format, &template.block);
template.tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
tex = vpipe->screen->texture_create(vpipe->screen, &template);
#include "pipe/p_context.h"
#include "pipe/p_state.h"
+#include "util/u_format.h"
#include "util/u_memory.h"
#include "nouveau_drm_api.h"
tmpl.format = format;
tmpl.width0 = width;
tmpl.height0 = height;
- pf_get_block(tmpl.format, &tmpl.block);
+ util_format_get_block(tmpl.format, &tmpl.block);
pt = api->texture_from_shared_handle(api, pscreen, &tmpl,
"front buffer", pitch, handle);
#include "softpipe/sp_texture.h"
#include "r300_context.h"
#include <X11/Xutil.h>
+#include "util/u_format.h"
+
struct radeon_vl_context
{
Display *display;
struct pipe_format_block block;
unsigned nblocksx, nblocksy, size;
- pf_get_block(format, &block);
+ util_format_get_block(format, &block);
nblocksx = pf_get_nblocksx(&block, width);
nblocksy = pf_get_nblocksy(&block, height);
tmpl.height0 = h;
tmpl.depth0 = 1;
tmpl.format = format;
- pf_get_block(tmpl.format, &tmpl.block);
+ util_format_get_block(tmpl.format, &tmpl.block);
tmpl.nblocksx[0] = pf_get_nblocksx(&tmpl.block, w);
tmpl.nblocksy[0] = pf_get_nblocksy(&tmpl.block, h);
#include "pipe/internal/p_winsys_screen.h"
#include "pipe/p_state.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
struct pipe_format_block block;
unsigned nblocksx, nblocksy;
- pf_get_block(format, &block);
+ util_format_get_block(format, &block);
nblocksx = pf_get_nblocksx(&block, width);
nblocksy = pf_get_nblocksy(&block, height);
*stride = round_up(nblocksx * block.size, alignment);
#include <pipe/internal/p_winsys_screen.h>
#include <pipe/p_state.h>
#include <pipe/p_inlines.h>
+#include <util/u_format.h>
#include <util/u_memory.h>
#include <util/u_math.h>
#include <softpipe/sp_winsys.h>
struct pipe_format_block block;
unsigned nblocksx, nblocksy;
- pf_get_block(format, &block);
+ util_format_get_block(format, &block);
nblocksx = pf_get_nblocksx(&block, width);
nblocksy = pf_get_nblocksy(&block, height);
*stride = align(nblocksx * block.size, ALIGNMENT);
#include "pipe/p_format.h"
#include "pipe/p_context.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "softpipe/sp_winsys.h"
struct pipe_format_block block;
unsigned nblocksx, nblocksy;
- pf_get_block(format, &block);
+ util_format_get_block(format, &block);
nblocksx = pf_get_nblocksx(&block, width);
nblocksy = pf_get_nblocksy(&block, height);
*stride = round_up(nblocksx * block.size, alignment);
#include "pipe/p_format.h"
#include "pipe/p_context.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
struct pipe_format_block block;
unsigned nblocksx, nblocksy;
- pf_get_block(format, &block);
+ util_format_get_block(format, &block);
nblocksx = pf_get_nblocksx(&block, width);
nblocksy = pf_get_nblocksy(&block, height);
*stride = round_up(nblocksx * block.size, alignment);
#include "pipe/p_format.h"
#include "pipe/p_context.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "llvmpipe/lp_winsys.h"
xm_dt->width = width;
xm_dt->height = height;
- pf_get_block(format, &xm_dt->block);
+ util_format_get_block(format, &xm_dt->block);
nblocksx = pf_get_nblocksx(&xm_dt->block, width);
nblocksy = pf_get_nblocksy(&xm_dt->block, height);
xm_dt->stride = align(nblocksx * xm_dt->block.size, alignment);
#include "pipe/p_format.h"
#include "pipe/p_context.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "softpipe/sp_winsys.h"
struct pipe_format_block block;
unsigned nblocksx, nblocksy, size;
- pf_get_block(format, &block);
+ util_format_get_block(format, &block);
nblocksx = pf_get_nblocksx(&block, width);
nblocksy = pf_get_nblocksy(&block, height);
*stride = align(nblocksx * block.size, alignment);
_mesa_free(strb->data);
assert(strb->format != PIPE_FORMAT_NONE);
- pf_get_block(strb->format, &block);
+ util_format_get_block(strb->format, &block);
strb->stride = pf_get_stride(&block, width);
size = pf_get_2d_size(&block, strb->stride, height);
memset(&template, 0, sizeof(template));
template.target = PIPE_TEXTURE_2D;
template.format = format;
- pf_get_block(format, &template.block);
+ util_format_get_block(format, &template.block);
template.width0 = width;
template.height0 = height;
template.depth0 = 1;
memset(&templ, 0, sizeof(templ));
templ.target = PIPE_TEXTURE_2D;
templ.format = st_mesa_format_to_pipe_format(mesa_format);
- pf_get_block(templ.format, &templ.block);
+ util_format_get_block(templ.format, &templ.block);
templ.width0 = width;
templ.height0 = height;
templ.depth0 = 1;
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
+#include "util/u_format.h"
#include "util/u_rect.h"
#include "util/u_math.h"
pt.width0 = width0;
pt.height0 = height0;
pt.depth0 = depth0;
- pf_get_block(format, &pt.block);
+ util_format_get_block(format, &pt.block);
pt.tex_usage = usage;
newtex = screen->texture_create(screen, &pt);