mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 00:20:09 +01:00
Add inline funtion to comput format size based on code in st_format.c.
Including state_tracker/st_format.h from pipe drivers is not an option since it uses GL* types and pipe/p_util.h will clash with main/imports.h.
This commit is contained in:
parent
7d1894c655
commit
609538f57c
1 changed files with 47 additions and 0 deletions
|
|
@ -366,4 +366,51 @@ static INLINE char *pf_sprint_name( char *str, uint format )
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static INLINE uint pf_get_component_bits( uint format, uint comp )
|
||||||
|
{
|
||||||
|
uint size;
|
||||||
|
|
||||||
|
if (pf_swizzle_x(format) == comp) {
|
||||||
|
size = pf_size_x(format);
|
||||||
|
}
|
||||||
|
else if (pf_swizzle_y(format) == comp) {
|
||||||
|
size = pf_size_y(format);
|
||||||
|
}
|
||||||
|
else if (pf_swizzle_z(format) == comp) {
|
||||||
|
size = pf_size_z(format);
|
||||||
|
}
|
||||||
|
else if (pf_swizzle_w(format) == comp) {
|
||||||
|
size = pf_size_w(format);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
size = 0;
|
||||||
|
}
|
||||||
|
return size << (pf_exp8(format) * 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
static INLINE uint pf_get_bits( uint format )
|
||||||
|
{
|
||||||
|
if (pf_layout(format) == PIPE_FORMAT_LAYOUT_RGBAZS) {
|
||||||
|
return
|
||||||
|
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 );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assert( pf_layout(format) == PIPE_FORMAT_LAYOUT_YCBCR );
|
||||||
|
|
||||||
|
/* TODO */
|
||||||
|
assert( 0 );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static INLINE uint pf_get_size( uint format ) {
|
||||||
|
assert(pf_get_bits(format) % 8 == 0);
|
||||||
|
return pf_get_bits(format) / 8;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue