diff options
author | Chia-I Wu <[email protected]> | 2014-07-24 09:32:34 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2014-07-24 09:33:33 +0800 |
commit | 2126541b0b6c15aa82c2ffb78ecc09d33a07ae53 (patch) | |
tree | b65db7a62a32c132f5300e1ec0439469e7166d39 /src | |
parent | 6bac86cd85bf85dd03df7e788232059dc63b9f65 (diff) |
ilo: allow for device-dependent format translation
Pass ilo_dev_info to all format translation functions.
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/ilo/ilo_format.c | 26 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_format.h | 29 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_gpe_gen6.c | 8 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_gpe_gen6.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_gpe_gen7.c | 6 |
5 files changed, 39 insertions, 32 deletions
diff --git a/src/gallium/drivers/ilo/ilo_format.c b/src/gallium/drivers/ilo/ilo_format.c index 953be8d802c..033946b4661 100644 --- a/src/gallium/drivers/ilo/ilo_format.c +++ b/src/gallium/drivers/ilo/ilo_format.c @@ -297,9 +297,10 @@ static const struct ilo_format_info ilo_format_table[] = { #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) ? @@ -311,7 +312,8 @@ lookup_format_info(enum pipe_format format, unsigned bind) * 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, @@ -581,7 +583,7 @@ ilo_is_format_supported(struct pipe_screen *screen, 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; @@ -611,31 +613,31 @@ ilo_is_format_supported(struct pipe_screen *screen, 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; } diff --git a/src/gallium/drivers/ilo/ilo_format.h b/src/gallium/drivers/ilo/ilo_format.h index 2ea7885694e..7d84c60a953 100644 --- a/src/gallium/drivers/ilo/ilo_format.h +++ b/src/gallium/drivers/ilo/ilo_format.h @@ -38,17 +38,19 @@ void 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: @@ -61,7 +63,7 @@ ilo_translate_format(enum pipe_format format, unsigned bind) 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: @@ -87,7 +89,7 @@ ilo_translate_format(enum pipe_format format, unsigned bind) 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: @@ -110,7 +112,7 @@ ilo_translate_format(enum pipe_format format, unsigned bind) 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: @@ -122,21 +124,24 @@ ilo_translate_format(enum pipe_format format, unsigned bind) } 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 */ diff --git a/src/gallium/drivers/ilo/ilo_gpe_gen6.c b/src/gallium/drivers/ilo/ilo_gpe_gen6.c index 11972b96897..0a9fd98152d 100644 --- a/src/gallium/drivers/ilo/ilo_gpe_gen6.c +++ b/src/gallium/drivers/ilo/ilo_gpe_gen6.c @@ -271,7 +271,7 @@ ve_init_cso(const struct ilo_dev_info *dev, 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] = @@ -1831,7 +1831,7 @@ ilo_gpe_init_view_surface_for_buffer_gen6(const struct ilo_dev_info *dev, * 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 */ @@ -1929,9 +1929,9 @@ ilo_gpe_init_view_surface_for_texture_gen6(const struct ilo_dev_info *dev, 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; diff --git a/src/gallium/drivers/ilo/ilo_gpe_gen6.h b/src/gallium/drivers/ilo/ilo_gpe_gen6.h index e5647184fd7..8e394ded95f 100644 --- a/src/gallium/drivers/ilo/ilo_gpe_gen6.h +++ b/src/gallium/drivers/ilo/ilo_gpe_gen6.h @@ -2124,7 +2124,7 @@ gen6_emit_BLEND_STATE(const struct ilo_dev_info *dev, 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; diff --git a/src/gallium/drivers/ilo/ilo_gpe_gen7.c b/src/gallium/drivers/ilo/ilo_gpe_gen7.c index 6d3397f2d62..cc666c80953 100644 --- a/src/gallium/drivers/ilo/ilo_gpe_gen7.c +++ b/src/gallium/drivers/ilo/ilo_gpe_gen7.c @@ -319,7 +319,7 @@ ilo_gpe_init_view_surface_for_buffer_gen7(const struct ilo_dev_info *dev, 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 */ @@ -447,9 +447,9 @@ ilo_gpe_init_view_surface_for_texture_gen7(const struct ilo_dev_info *dev, 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; |