Move pf_get_bits/size() to u_format auxiliary module.
This commit is contained in:
@@ -183,6 +183,35 @@ util_format_get_block(enum pipe_format format,
|
||||
block->height = desc->block.height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return total bits needed for the pixel format.
|
||||
*/
|
||||
static INLINE uint
|
||||
util_format_get_bits(enum pipe_format format)
|
||||
{
|
||||
const struct util_format_description *desc = util_format_description(format);
|
||||
|
||||
assert(format);
|
||||
if (!format) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return desc->block.bits / (desc->block.width * desc->block.height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return bytes per pixel for the given format.
|
||||
*/
|
||||
static INLINE uint
|
||||
util_format_get_size(enum pipe_format format)
|
||||
{
|
||||
uint bits = util_format_get_bits(format);
|
||||
|
||||
assert(bits % 8 == 0);
|
||||
|
||||
return bits / 8;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Format access functions.
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "pipe/p_shader_tokens.h"
|
||||
#include "pipe/p_state.h"
|
||||
|
||||
#include "util/u_format.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_draw_quad.h"
|
||||
#include "util/u_gen_mipmap.h"
|
||||
@@ -996,7 +997,7 @@ reduce_2d(enum pipe_format pformat,
|
||||
{
|
||||
enum dtype datatype;
|
||||
uint comps;
|
||||
const int bpt = pf_get_size(pformat);
|
||||
const int bpt = util_format_get_size(pformat);
|
||||
const ubyte *srcA, *srcB;
|
||||
ubyte *dst;
|
||||
int row;
|
||||
@@ -1035,7 +1036,7 @@ reduce_3d(enum pipe_format pformat,
|
||||
int dstWidth, int dstHeight, int dstDepth,
|
||||
int dstRowStride, ubyte *dstPtr)
|
||||
{
|
||||
const int bpt = pf_get_size(pformat);
|
||||
const int bpt = util_format_get_size(pformat);
|
||||
const int border = 0;
|
||||
int img, row;
|
||||
int bytesPerSrcImage, bytesPerDstImage;
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#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"
|
||||
|
||||
@@ -408,7 +410,7 @@ cell_transfer_map(struct pipe_screen *screen, struct pipe_transfer *transfer)
|
||||
|
||||
if (transfer->usage & PIPE_TRANSFER_READ) {
|
||||
/* need to untwiddle the texture to make a linear version */
|
||||
const uint bpp = pf_get_size(ct->base.format);
|
||||
const uint bpp = util_format_get_size(ct->base.format);
|
||||
if (bpp == 4) {
|
||||
const uint *src = (uint *) (ct->mapped + ctrans->offset);
|
||||
uint *dst = ctrans->map;
|
||||
@@ -451,7 +453,7 @@ cell_transfer_unmap(struct pipe_screen *screen,
|
||||
/* The user wrote new texture data into the mapped buffer.
|
||||
* We need to convert the new linear data into the twiddled/tiled format.
|
||||
*/
|
||||
const uint bpp = pf_get_size(ct->base.format);
|
||||
const uint bpp = util_format_get_size(ct->base.format);
|
||||
if (bpp == 4) {
|
||||
const uint *src = ctrans->map;
|
||||
uint *dst = (uint *) (ct->mapped + ctrans->offset);
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
/* r300_emit: Functions for emitting state. */
|
||||
|
||||
#include "util/u_format.h"
|
||||
#include "util/u_math.h"
|
||||
|
||||
#include "r300_context.h"
|
||||
@@ -631,10 +632,10 @@ void r300_emit_aos(struct r300_context* r300, unsigned offset)
|
||||
for (i = 0; i < aos_count - 1; i += 2) {
|
||||
int buf_num1 = velem[i].vertex_buffer_index;
|
||||
int buf_num2 = velem[i+1].vertex_buffer_index;
|
||||
assert(vbuf[buf_num1].stride % 4 == 0 && pf_get_size(velem[i].src_format) % 4 == 0);
|
||||
assert(vbuf[buf_num2].stride % 4 == 0 && pf_get_size(velem[i+1].src_format) % 4 == 0);
|
||||
OUT_CS((pf_get_size(velem[i].src_format) >> 2) | (vbuf[buf_num1].stride << 6) |
|
||||
(pf_get_size(velem[i+1].src_format) << 14) | (vbuf[buf_num2].stride << 22));
|
||||
assert(vbuf[buf_num1].stride % 4 == 0 && util_format_get_size(velem[i].src_format) % 4 == 0);
|
||||
assert(vbuf[buf_num2].stride % 4 == 0 && util_format_get_size(velem[i+1].src_format) % 4 == 0);
|
||||
OUT_CS((util_format_get_size(velem[i].src_format) >> 2) | (vbuf[buf_num1].stride << 6) |
|
||||
(util_format_get_size(velem[i+1].src_format) << 14) | (vbuf[buf_num2].stride << 22));
|
||||
OUT_CS(vbuf[buf_num1].buffer_offset + velem[i].src_offset +
|
||||
offset * vbuf[buf_num1].stride);
|
||||
OUT_CS(vbuf[buf_num2].buffer_offset + velem[i+1].src_offset +
|
||||
@@ -642,8 +643,8 @@ void r300_emit_aos(struct r300_context* r300, unsigned offset)
|
||||
}
|
||||
if (aos_count & 1) {
|
||||
int buf_num = velem[i].vertex_buffer_index;
|
||||
assert(vbuf[buf_num].stride % 4 == 0 && pf_get_size(velem[i].src_format) % 4 == 0);
|
||||
OUT_CS((pf_get_size(velem[i].src_format) >> 2) | (vbuf[buf_num].stride << 6));
|
||||
assert(vbuf[buf_num].stride % 4 == 0 && util_format_get_size(velem[i].src_format) % 4 == 0);
|
||||
OUT_CS((util_format_get_size(velem[i].src_format) >> 2) | (vbuf[buf_num].stride << 6));
|
||||
OUT_CS(vbuf[buf_num].buffer_offset + velem[i].src_offset +
|
||||
offset * vbuf[buf_num].stride);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
*/
|
||||
|
||||
#include "pipe/p_inlines.h"
|
||||
#include "util/u_format.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_tile.h"
|
||||
#include "sp_tile_cache.h"
|
||||
@@ -238,7 +239,7 @@ clear_tile(struct softpipe_cached_tile *tile,
|
||||
{
|
||||
uint i, j;
|
||||
|
||||
switch (pf_get_size(format)) {
|
||||
switch (util_format_get_size(format)) {
|
||||
case 1:
|
||||
memset(tile->data.any, clear_value, TILE_SIZE * TILE_SIZE);
|
||||
break;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "pipe/p_inlines.h"
|
||||
#include "pipe/p_defines.h"
|
||||
#include "util/u_format.h"
|
||||
#include "util/u_math.h"
|
||||
#include "translate/translate.h"
|
||||
|
||||
@@ -210,7 +211,7 @@ static int update_zero_stride( struct svga_context *svga,
|
||||
mapped_buffer = pipe_buffer_map_range(svga->pipe.screen,
|
||||
vbuffer->buffer,
|
||||
vel->src_offset,
|
||||
pf_get_size(vel->src_format),
|
||||
util_format_get_size(vel->src_format),
|
||||
PIPE_BUFFER_USAGE_CPU_READ);
|
||||
translate->set_buffer(translate, vel->vertex_buffer_index,
|
||||
mapped_buffer,
|
||||
|
||||
@@ -422,42 +422,6 @@ static INLINE uint pf_get_component_bits( enum pipe_format format, uint comp )
|
||||
return size << (pf_mixed_scale8( format ) * 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return total bits needed for the pixel format.
|
||||
*/
|
||||
static INLINE uint pf_get_bits( enum pipe_format format )
|
||||
{
|
||||
switch (pf_layout(format)) {
|
||||
case PIPE_FORMAT_LAYOUT_RGBAZS:
|
||||
case PIPE_FORMAT_LAYOUT_MIXED:
|
||||
return
|
||||
pf_get_component_bits( format, PIPE_FORMAT_COMP_0 ) +
|
||||
pf_get_component_bits( format, PIPE_FORMAT_COMP_1 ) +
|
||||
pf_get_component_bits( format, PIPE_FORMAT_COMP_R ) +
|
||||
pf_get_component_bits( format, PIPE_FORMAT_COMP_G ) +
|
||||
pf_get_component_bits( format, PIPE_FORMAT_COMP_B ) +
|
||||
pf_get_component_bits( format, PIPE_FORMAT_COMP_A ) +
|
||||
pf_get_component_bits( format, PIPE_FORMAT_COMP_Z ) +
|
||||
pf_get_component_bits( format, PIPE_FORMAT_COMP_S );
|
||||
case PIPE_FORMAT_LAYOUT_YCBCR:
|
||||
assert( format == PIPE_FORMAT_YCBCR || format == PIPE_FORMAT_YCBCR_REV );
|
||||
/* return effective bits per pixel */
|
||||
return 16;
|
||||
default:
|
||||
assert( 0 );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return bytes per pixel for the given format.
|
||||
*/
|
||||
static INLINE uint pf_get_size( enum pipe_format format )
|
||||
{
|
||||
assert(pf_get_bits(format) % 8 == 0);
|
||||
return pf_get_bits(format) / 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describe accurately the pixel format.
|
||||
*
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#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"
|
||||
@@ -147,8 +148,8 @@ gdi_llvmpipe_displaytarget_create(struct llvmpipe_winsys *winsys,
|
||||
gdt->width = width;
|
||||
gdt->height = height;
|
||||
|
||||
bpp = pf_get_bits(format);
|
||||
cpp = pf_get_size(format);
|
||||
bpp = util_format_get_bits(format);
|
||||
cpp = util_format_get_size(format);
|
||||
|
||||
gdt->stride = round_up(width * cpp, alignment);
|
||||
gdt->size = gdt->stride * height;
|
||||
|
||||
@@ -284,10 +284,10 @@ gdi_softpipe_present(struct pipe_screen *screen,
|
||||
|
||||
memset(&bmi, 0, sizeof(BITMAPINFO));
|
||||
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bmi.bmiHeader.biWidth = texture->stride[surface->level] / pf_get_size(surface->format);
|
||||
bmi.bmiHeader.biWidth = texture->stride[surface->level] / util_format_get_size(surface->format);
|
||||
bmi.bmiHeader.biHeight= -(long)surface->height;
|
||||
bmi.bmiHeader.biPlanes = 1;
|
||||
bmi.bmiHeader.biBitCount = pf_get_bits(surface->format);
|
||||
bmi.bmiHeader.biBitCount = util_format_get_bits(surface->format);
|
||||
bmi.bmiHeader.biCompression = BI_RGB;
|
||||
bmi.bmiHeader.biSizeImage = 0;
|
||||
bmi.bmiHeader.biXPelsPerMeter = 0;
|
||||
|
||||
@@ -834,7 +834,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
|
||||
/* copy/pack data into user buffer */
|
||||
if (st_equal_formats(stImage->pt->format, format, type)) {
|
||||
/* memcpy */
|
||||
const uint bytesPerRow = width * pf_get_size(stImage->pt->format);
|
||||
const uint bytesPerRow = width * util_format_get_size(stImage->pt->format);
|
||||
ubyte *map = screen->transfer_map(screen, tex_xfer);
|
||||
GLuint row;
|
||||
for (row = 0; row < height; row++) {
|
||||
|
||||
Reference in New Issue
Block a user