[libre-riscv-dev] evaluation of bit-witdh scoreboards
Jacob Lifshay
programmerjake at gmail.com
Mon Dec 17 02:46:39 GMT 2018
On Sun, Dec 16, 2018, 17:51 Luke Kenneth Casson Leighton <lkcl at lkcl.net
wrote:
> Jacob whats requirements of pixel conversion op, whats it look like as c
> pseudocode. Also texture op, roughly. Mainly, whats inputs and outputs.
>
> Need to assess.
>
assume there is a 12-bit unsigned type: uint12_t
float clamp(float v, float minv, float maxv)
{
return fmax(fmin(v, maxv), minv);
}
uint12_t float_to_u12(float v)
{
return (uint12_t)round(clamp(v, 0x0, 0xFFF));
}
const uint8_t encode_sRGB_lut[1 << 12] = {...};
const float decode_sRGB_lut[1 << 8] = {...};
float decode_sRGB_channel(uint8_t v)
{
return decode_sRGB_lut[v];
}
uint8_t encode_sRGB_channel(float v)
{
return encode_sRGB_lut[float_to_u12(v)];
}
uint8_t encode_u8_channel(float v)
{
return (uint8_t)round(clamp(v, 0, 0xFF));
}
float decode_u8_channel(uint8_t v)
{
return (float)v / 0xFF;
}
// common read from color buffer
f32x4 decode_sRGB(u8x4 v)
{
return (f32x4){
decode_sRGB_channel(v[0]),
decode_sRGB_channel(v[1]),
decode_sRGB_channel(v[2]),
decode_u8_channel(v[3])
};
}
// common read from color buffer
f32x4 decode_u8(u8x4 v)
{
return (f32x4){
decode_u8_channel(v[0]),
decode_u8_channel(v[1]),
decode_u8_channel(v[2]),
decode_u8_channel(v[3])
};
}
// common write to color buffer
u8x4 encode_sRGB(f32x4 v)
{
return (u8x4){
encode_sRGB_channel(v[0]),
encode_sRGB_channel(v[1]),
encode_sRGB_channel(v[2]),
encode_u8_channel(v[3])
};
}
// common write to color buffer
u8x4 encode_u8(f32x4 v)
{
return (u8x4){
encode_u8_channel(v[0]),
encode_u8_channel(v[1]),
encode_u8_channel(v[2]),
encode_u8_channel(v[3])
};
}
The simplest texture read operations are basically several decode_sRGB or
decode_u8 calls then interpolation
Since we're processing several pixels simultaneously, we need to vectorize
by an additional factor of 4*N
Jacob
>
More information about the libre-riscv-dev
mailing list