Pass ilo_dev_info to all format translation functions.
#undef FI_INITIALIZER
static const struct ilo_format_info *
-lookup_format_info(enum pipe_format format, unsigned bind)
+lookup_format_info(const struct ilo_dev_info *dev,
+ enum pipe_format format, unsigned bind)
{
- const int surfaceformat = ilo_translate_format(format, bind);
+ const int surfaceformat = ilo_translate_format(dev, format, bind);
return (surfaceformat >= 0 && surfaceformat < Elements(ilo_format_table) &&
ilo_format_table[surfaceformat].exists) ?
* format. Return -1 on errors.
*/
int
-ilo_translate_color_format(enum pipe_format format)
+ilo_translate_color_format(const struct ilo_dev_info *dev,
+ enum pipe_format format)
{
static const int format_mapping[PIPE_FORMAT_COUNT] = {
[PIPE_FORMAT_NONE] = 0,
unsigned bindings)
{
struct ilo_screen *is = ilo_screen(screen);
- const int gen = is->dev.gen;
+ const struct ilo_dev_info *dev = &is->dev;
const bool is_pure_int = util_format_is_pure_integer(format);
const struct ilo_format_info *info;
unsigned bind;
bind = (bindings & PIPE_BIND_RENDER_TARGET);
if (bind) {
- info = lookup_format_info(format, bind);
+ info = lookup_format_info(dev, format, bind);
- if (gen < info->render_target)
+ if (dev->gen < info->render_target)
return false;
- if (!is_pure_int && gen < info->alpha_blend)
+ if (!is_pure_int && dev->gen < info->alpha_blend)
return false;
}
bind = (bindings & PIPE_BIND_SAMPLER_VIEW);
if (bind) {
- info = lookup_format_info(format, bind);
+ info = lookup_format_info(dev, format, bind);
- if (gen < info->sampling)
+ if (dev->gen < info->sampling)
return false;
- if (!is_pure_int && gen < info->filtering)
+ if (!is_pure_int && dev->gen < info->filtering)
return false;
}
bind = (bindings & PIPE_BIND_VERTEX_BUFFER);
if (bind) {
- info = lookup_format_info(format, bind);
+ info = lookup_format_info(dev, format, bind);
- if (gen < info->input_vb)
+ if (dev->gen < info->input_vb)
return false;
}
ilo_init_format_functions(struct ilo_screen *is);
int
-ilo_translate_color_format(enum pipe_format format);
+ilo_translate_color_format(const struct ilo_dev_info *dev,
+ enum pipe_format format);
/**
* Translate a pipe format to a hardware surface format suitable for
* the given purpose. Return -1 on errors.
*
* This is an inline function not only for performance reasons. There are
- * caveats that the callers should that before calling this function.
+ * caveats that the callers should be aware of before calling this function.
*/
static inline int
-ilo_translate_format(enum pipe_format format, unsigned bind)
+ilo_translate_format(const struct ilo_dev_info *dev,
+ enum pipe_format format, unsigned bind)
{
switch (bind) {
case PIPE_BIND_RENDER_TARGET:
case PIPE_FORMAT_B8G8R8X8_UNORM:
return GEN6_FORMAT_B8G8R8A8_UNORM;
default:
- return ilo_translate_color_format(format);
+ return ilo_translate_color_format(dev, format);
}
break;
case PIPE_BIND_SAMPLER_VIEW:
case PIPE_FORMAT_ETC1_RGB8:
return GEN6_FORMAT_R8G8B8X8_UNORM;
default:
- return ilo_translate_color_format(format);
+ return ilo_translate_color_format(dev, format);
}
break;
case PIPE_BIND_VERTEX_BUFFER:
case PIPE_FORMAT_R8G8B8_SINT:
return GEN6_FORMAT_R8G8B8A8_SINT;
default:
- return ilo_translate_color_format(format);
+ return ilo_translate_color_format(dev, format);
}
break;
default:
}
static inline int
-ilo_translate_render_format(enum pipe_format format)
+ilo_translate_render_format(const struct ilo_dev_info *dev,
+ enum pipe_format format)
{
- return ilo_translate_format(format, PIPE_BIND_RENDER_TARGET);
+ return ilo_translate_format(dev, format, PIPE_BIND_RENDER_TARGET);
}
static inline int
-ilo_translate_texture_format(enum pipe_format format)
+ilo_translate_texture_format(const struct ilo_dev_info *dev,
+ enum pipe_format format)
{
- return ilo_translate_format(format, PIPE_BIND_SAMPLER_VIEW);
+ return ilo_translate_format(dev, format, PIPE_BIND_SAMPLER_VIEW);
}
static inline int
-ilo_translate_vertex_format(enum pipe_format format)
+ilo_translate_vertex_format(const struct ilo_dev_info *dev,
+ enum pipe_format format)
{
- return ilo_translate_format(format, PIPE_BIND_VERTEX_BUFFER);
+ return ilo_translate_format(dev, format, PIPE_BIND_VERTEX_BUFFER);
}
#endif /* ILO_FORMAT_H */
GEN6_VFCOMP_STORE_1_FP;
}
- format = ilo_translate_vertex_format(state->src_format);
+ format = ilo_translate_vertex_format(dev, state->src_format);
STATIC_ASSERT(Elements(cso->payload) >= 2);
cso->payload[0] =
* structure in a buffer.
*/
- surface_format = ilo_translate_color_format(elem_format);
+ surface_format = ilo_translate_color_format(dev, elem_format);
num_entries = size / struct_size;
/* see if there is enough space to fit another element */
format = PIPE_FORMAT_Z32_FLOAT;
if (is_rt)
- surface_format = ilo_translate_render_format(format);
+ surface_format = ilo_translate_render_format(dev, format);
else
- surface_format = ilo_translate_texture_format(format);
+ surface_format = ilo_translate_texture_format(dev, format);
assert(surface_format >= 0);
width = tex->base.width0;
switch (format_desc->format) {
case PIPE_FORMAT_B8G8R8X8_UNORM:
/* force alpha to one when the HW format has alpha */
- assert(ilo_translate_render_format(PIPE_FORMAT_B8G8R8X8_UNORM)
+ assert(ilo_translate_render_format(dev, PIPE_FORMAT_B8G8R8X8_UNORM)
== GEN6_FORMAT_B8G8R8A8_UNORM);
rt_dst_alpha_forced_one = true;
break;
surface_type = (structured) ? GEN7_SURFTYPE_STRBUF : GEN6_SURFTYPE_BUFFER;
surface_format = (typed) ?
- ilo_translate_color_format(elem_format) : GEN6_FORMAT_RAW;
+ ilo_translate_color_format(dev, elem_format) : GEN6_FORMAT_RAW;
num_entries = size / struct_size;
/* see if there is enough space to fit another element */
format = PIPE_FORMAT_Z32_FLOAT;
if (is_rt)
- surface_format = ilo_translate_render_format(format);
+ surface_format = ilo_translate_render_format(dev, format);
else
- surface_format = ilo_translate_texture_format(format);
+ surface_format = ilo_translate_texture_format(dev, format);
assert(surface_format >= 0);
width = tex->base.width0;