diff options
Diffstat (limited to 'src/gallium/drivers/ilo')
-rw-r--r-- | src/gallium/drivers/ilo/Makefile.sources | 4 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/core/ilo_format.c (renamed from src/gallium/drivers/ilo/ilo_format.c) | 218 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/core/ilo_format.h (renamed from src/gallium/drivers/ilo/ilo_format.h) | 50 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_builder_3d_bottom.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_resource.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_screen.c | 51 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_state_3d_bottom.c | 10 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_state_3d_top.c | 16 |
8 files changed, 184 insertions, 169 deletions
diff --git a/src/gallium/drivers/ilo/Makefile.sources b/src/gallium/drivers/ilo/Makefile.sources index 6083e24f46d..29bb9f6e446 100644 --- a/src/gallium/drivers/ilo/Makefile.sources +++ b/src/gallium/drivers/ilo/Makefile.sources @@ -4,6 +4,8 @@ C_SOURCES := \ core/ilo_debug.h \ core/ilo_dev.c \ core/ilo_dev.h \ + core/ilo_format.c \ + core/ilo_format.h \ core/ilo_fence.h \ core/intel_winsys.h \ ilo_blit.c \ @@ -30,8 +32,6 @@ C_SOURCES := \ ilo_cp.h \ ilo_draw.c \ ilo_draw.h \ - ilo_format.c \ - ilo_format.h \ ilo_gpgpu.c \ ilo_gpgpu.h \ ilo_layout.c \ diff --git a/src/gallium/drivers/ilo/ilo_format.c b/src/gallium/drivers/ilo/core/ilo_format.c index 1fb36a03cf1..280e499d54a 100644 --- a/src/gallium/drivers/ilo/ilo_format.c +++ b/src/gallium/drivers/ilo/core/ilo_format.c @@ -26,9 +26,6 @@ */ #include "genhw/genhw.h" -#include "vl/vl_video_buffer.h" - -#include "ilo_screen.h" #include "ilo_format.h" struct ilo_vf_cap { @@ -406,12 +403,95 @@ static const struct ilo_dp_cap ilo_dp_caps[] = { #undef CAP }; +bool +ilo_format_support_vb(const struct ilo_dev *dev, + enum pipe_format format) +{ + const int idx = ilo_format_translate(dev, format, PIPE_BIND_VERTEX_BUFFER); + const struct ilo_vf_cap *cap = (idx >= 0 && idx < Elements(ilo_vf_caps)) ? + &ilo_vf_caps[idx] : NULL; + + return (cap && cap->vertex_element && + ilo_dev_gen(dev) >= cap->vertex_element); +} + +bool +ilo_format_support_sol(const struct ilo_dev *dev, + enum pipe_format format) +{ + const int idx = ilo_format_translate(dev, format, PIPE_BIND_STREAM_OUTPUT); + const struct ilo_sol_cap *cap = (idx >= 0 && idx < Elements(ilo_sol_caps)) ? + &ilo_sol_caps[idx] : NULL; + + return (cap && cap->buffer && ilo_dev_gen(dev) >= cap->buffer); +} + +bool +ilo_format_support_sampler(const struct ilo_dev *dev, + enum pipe_format format) +{ + const int idx = ilo_format_translate(dev, format, PIPE_BIND_SAMPLER_VIEW); + const struct ilo_sampler_cap *cap = (idx >= 0 && + idx < Elements(ilo_sampler_caps)) ? &ilo_sampler_caps[idx] : NULL; + + if (!cap || !cap->sampling) + return false; + + assert(!cap->filtering || cap->filtering >= cap->sampling); + + if (util_format_is_pure_integer(format)) + return (ilo_dev_gen(dev) >= cap->sampling); + else if (cap->filtering) + return (ilo_dev_gen(dev) >= cap->filtering); + else + return false; +} + +bool +ilo_format_support_rt(const struct ilo_dev *dev, + enum pipe_format format) +{ + const int idx = ilo_format_translate(dev, format, PIPE_BIND_RENDER_TARGET); + const struct ilo_dp_cap *cap = (idx >= 0 && idx < Elements(ilo_dp_caps)) ? + &ilo_dp_caps[idx] : NULL; + + if (!cap || !cap->rt_write) + return false; + + assert(!cap->rt_write_blending || cap->rt_write_blending >= cap->rt_write); + + if (util_format_is_pure_integer(format)) + return (ilo_dev_gen(dev) >= cap->rt_write); + else if (cap->rt_write_blending) + return (ilo_dev_gen(dev) >= cap->rt_write_blending); + else + return false; +} + +bool +ilo_format_support_zs(const struct ilo_dev *dev, + enum pipe_format format) +{ + switch (format) { + case PIPE_FORMAT_Z16_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_Z32_FLOAT: + case PIPE_FORMAT_Z24_UNORM_S8_UINT: + case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: + return true; + case PIPE_FORMAT_S8_UINT: + /* TODO separate stencil */ + default: + return false; + } +} + /** * Translate a color (non-depth/stencil) pipe format to the matching hardware * format. Return -1 on errors. */ int -ilo_translate_color_format(const struct ilo_dev *dev, +ilo_format_translate_color(const struct ilo_dev *dev, enum pipe_format format) { static const int format_mapping[PIPE_FORMAT_COUNT] = { @@ -673,133 +753,3 @@ ilo_translate_color_format(const struct ilo_dev *dev, return sfmt; } - -static bool -ilo_format_supports_zs(const struct ilo_dev *dev, - enum pipe_format format) -{ - switch (format) { - case PIPE_FORMAT_Z16_UNORM: - case PIPE_FORMAT_Z24X8_UNORM: - case PIPE_FORMAT_Z32_FLOAT: - case PIPE_FORMAT_Z24_UNORM_S8_UINT: - case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: - return true; - case PIPE_FORMAT_S8_UINT: - /* TODO separate stencil */ - default: - return false; - } -} - -static bool -ilo_format_supports_rt(const struct ilo_dev *dev, - enum pipe_format format) -{ - const int idx = ilo_translate_format(dev, format, PIPE_BIND_RENDER_TARGET); - const struct ilo_dp_cap *cap = (idx >= 0 && idx < Elements(ilo_dp_caps)) ? - &ilo_dp_caps[idx] : NULL; - - if (!cap || !cap->rt_write) - return false; - - assert(!cap->rt_write_blending || cap->rt_write_blending >= cap->rt_write); - - if (util_format_is_pure_integer(format)) - return (ilo_dev_gen(dev) >= cap->rt_write); - else if (cap->rt_write_blending) - return (ilo_dev_gen(dev) >= cap->rt_write_blending); - else - return false; -} - -static bool -ilo_format_supports_sampler(const struct ilo_dev *dev, - enum pipe_format format) -{ - const int idx = ilo_translate_format(dev, format, PIPE_BIND_SAMPLER_VIEW); - const struct ilo_sampler_cap *cap = (idx >= 0 && - idx < Elements(ilo_sampler_caps)) ? &ilo_sampler_caps[idx] : NULL; - - if (!cap || !cap->sampling) - return false; - - assert(!cap->filtering || cap->filtering >= cap->sampling); - - if (util_format_is_pure_integer(format)) - return (ilo_dev_gen(dev) >= cap->sampling); - else if (cap->filtering) - return (ilo_dev_gen(dev) >= cap->filtering); - else - return false; -} - -static bool -ilo_format_supports_vb(const struct ilo_dev *dev, - enum pipe_format format) -{ - const int idx = ilo_translate_format(dev, format, PIPE_BIND_VERTEX_BUFFER); - const struct ilo_vf_cap *cap = (idx >= 0 && idx < Elements(ilo_vf_caps)) ? - &ilo_vf_caps[idx] : NULL; - - return (cap && cap->vertex_element && - ilo_dev_gen(dev) >= cap->vertex_element); -} - -static boolean -ilo_is_format_supported(struct pipe_screen *screen, - enum pipe_format format, - enum pipe_texture_target target, - unsigned sample_count, - unsigned bindings) -{ - struct ilo_screen *is = ilo_screen(screen); - const struct ilo_dev *dev = &is->dev; - unsigned bind; - - if (!util_format_is_supported(format, bindings)) - return false; - - /* no MSAA support yet */ - if (sample_count > 1) - return false; - - bind = (bindings & PIPE_BIND_DEPTH_STENCIL); - if (bind && !ilo_format_supports_zs(dev, format)) - return false; - - bind = (bindings & PIPE_BIND_RENDER_TARGET); - if (bind && !ilo_format_supports_rt(dev, format)) - return false; - - bind = (bindings & PIPE_BIND_SAMPLER_VIEW); - if (bind && !ilo_format_supports_sampler(dev, format)) - return false; - - bind = (bindings & PIPE_BIND_VERTEX_BUFFER); - if (bind && !ilo_format_supports_vb(dev, format)) - return false; - - (void) ilo_sol_caps; - - return true; -} - -static boolean -ilo_is_video_format_supported(struct pipe_screen *screen, - enum pipe_format format, - enum pipe_video_profile profile, - enum pipe_video_entrypoint entrypoint) -{ - return vl_video_buffer_is_format_supported(screen, format, profile, entrypoint); -} - -/** - * Initialize format-related functions. - */ -void -ilo_init_format_functions(struct ilo_screen *is) -{ - is->base.is_format_supported = ilo_is_format_supported; - is->base.is_video_format_supported = ilo_is_video_format_supported; -} diff --git a/src/gallium/drivers/ilo/ilo_format.h b/src/gallium/drivers/ilo/core/ilo_format.h index 1af1ea8e909..6b73ea1dad7 100644 --- a/src/gallium/drivers/ilo/ilo_format.h +++ b/src/gallium/drivers/ilo/core/ilo_format.h @@ -29,16 +29,31 @@ #define ILO_FORMAT_H #include "genhw/genhw.h" +#include "ilo_core.h" +#include "ilo_dev.h" -#include "ilo_common.h" +bool +ilo_format_support_vb(const struct ilo_dev *dev, + enum pipe_format format); -struct ilo_screen; +bool +ilo_format_support_sol(const struct ilo_dev *dev, + enum pipe_format format); -void -ilo_init_format_functions(struct ilo_screen *is); +bool +ilo_format_support_sampler(const struct ilo_dev *dev, + enum pipe_format format); + +bool +ilo_format_support_rt(const struct ilo_dev *dev, + enum pipe_format format); + +bool +ilo_format_support_zs(const struct ilo_dev *dev, + enum pipe_format format); int -ilo_translate_color_format(const struct ilo_dev *dev, +ilo_format_translate_color(const struct ilo_dev *dev, enum pipe_format format); /** @@ -49,7 +64,7 @@ ilo_translate_color_format(const struct ilo_dev *dev, * caveats that the callers should be aware of before calling this function. */ static inline int -ilo_translate_format(const struct ilo_dev *dev, +ilo_format_translate(const struct ilo_dev *dev, enum pipe_format format, unsigned bind) { switch (bind) { @@ -63,7 +78,7 @@ ilo_translate_format(const struct ilo_dev *dev, case PIPE_FORMAT_B8G8R8X8_UNORM: return GEN6_FORMAT_B8G8R8A8_UNORM; default: - return ilo_translate_color_format(dev, format); + return ilo_format_translate_color(dev, format); } break; case PIPE_BIND_SAMPLER_VIEW: @@ -89,12 +104,12 @@ ilo_translate_format(const struct ilo_dev *dev, case PIPE_FORMAT_ETC1_RGB8: return GEN6_FORMAT_R8G8B8X8_UNORM; default: - return ilo_translate_color_format(dev, format); + return ilo_format_translate_color(dev, format); } break; case PIPE_BIND_VERTEX_BUFFER: if (ilo_dev_gen(dev) >= ILO_GEN(7.5)) - return ilo_translate_color_format(dev, format); + return ilo_format_translate_color(dev, format); /* * Some 3-component formats are not supported as vertex element formats. @@ -115,9 +130,12 @@ ilo_translate_format(const struct ilo_dev *dev, case PIPE_FORMAT_R8G8B8_SINT: return GEN6_FORMAT_R8G8B8A8_SINT; default: - return ilo_translate_color_format(dev, format); + return ilo_format_translate_color(dev, format); } break; + case PIPE_BIND_STREAM_OUTPUT: + return ilo_format_translate_color(dev, format); + break; default: assert(!"cannot translate format"); break; @@ -127,24 +145,24 @@ ilo_translate_format(const struct ilo_dev *dev, } static inline int -ilo_translate_render_format(const struct ilo_dev *dev, +ilo_format_translate_render(const struct ilo_dev *dev, enum pipe_format format) { - return ilo_translate_format(dev, format, PIPE_BIND_RENDER_TARGET); + return ilo_format_translate(dev, format, PIPE_BIND_RENDER_TARGET); } static inline int -ilo_translate_texture_format(const struct ilo_dev *dev, +ilo_format_translate_texture(const struct ilo_dev *dev, enum pipe_format format) { - return ilo_translate_format(dev, format, PIPE_BIND_SAMPLER_VIEW); + return ilo_format_translate(dev, format, PIPE_BIND_SAMPLER_VIEW); } static inline int -ilo_translate_vertex_format(const struct ilo_dev *dev, +ilo_format_translate_vertex(const struct ilo_dev *dev, enum pipe_format format) { - return ilo_translate_format(dev, format, PIPE_BIND_VERTEX_BUFFER); + return ilo_format_translate(dev, format, PIPE_BIND_VERTEX_BUFFER); } #endif /* ILO_FORMAT_H */ diff --git a/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h b/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h index cad8bf275e9..ace2304276c 100644 --- a/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h +++ b/src/gallium/drivers/ilo/ilo_builder_3d_bottom.h @@ -29,10 +29,10 @@ #define ILO_BUILDER_3D_BOTTOM_H #include "genhw/genhw.h" +#include "core/ilo_format.h" #include "core/intel_winsys.h" #include "ilo_common.h" -#include "ilo_format.h" #include "ilo_shader.h" #include "ilo_builder.h" #include "ilo_builder_3d_top.h" diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c index 344993680aa..8e59e0d0bb2 100644 --- a/src/gallium/drivers/ilo/ilo_resource.c +++ b/src/gallium/drivers/ilo/ilo_resource.c @@ -452,7 +452,7 @@ buf_create(struct pipe_screen *screen, const struct pipe_resource *templ) if ((templ->bind & PIPE_BIND_VERTEX_BUFFER) && ilo_dev_gen(&is->dev) < ILO_GEN(7.5)) { /* - * As noted in ilo_translate_format(), we treat some 3-component formats + * As noted in ilo_format_translate(), we treat some 3-component formats * as 4-component formats to work around hardware limitations. Imagine * the case where the vertex buffer holds a single * PIPE_FORMAT_R16G16B16_FLOAT vertex, and buf->bo_size is 6. The diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c index 039e91611b8..918af0820de 100644 --- a/src/gallium/drivers/ilo/ilo_screen.c +++ b/src/gallium/drivers/ilo/ilo_screen.c @@ -32,10 +32,10 @@ #include "vl/vl_video_buffer.h" #include "genhw/genhw.h" /* for GEN6_REG_TIMESTAMP */ #include "core/ilo_fence.h" +#include "core/ilo_format.h" #include "core/intel_winsys.h" #include "ilo_context.h" -#include "ilo_format.h" #include "ilo_resource.h" #include "ilo_transfer.h" /* for ILO_TRANSFER_MAP_BUFFER_ALIGNMENT */ #include "ilo_public.h" @@ -580,6 +580,51 @@ ilo_get_timestamp(struct pipe_screen *screen) return (uint64_t) timestamp.dw[1] * 80; } +static boolean +ilo_is_format_supported(struct pipe_screen *screen, + enum pipe_format format, + enum pipe_texture_target target, + unsigned sample_count, + unsigned bindings) +{ + struct ilo_screen *is = ilo_screen(screen); + const struct ilo_dev *dev = &is->dev; + + if (!util_format_is_supported(format, bindings)) + return false; + + /* no MSAA support yet */ + if (sample_count > 1) + return false; + + if ((bindings & PIPE_BIND_DEPTH_STENCIL) && + !ilo_format_support_zs(dev, format)) + return false; + + if ((bindings & PIPE_BIND_RENDER_TARGET) && + !ilo_format_support_rt(dev, format)) + return false; + + if ((bindings & PIPE_BIND_SAMPLER_VIEW) && + !ilo_format_support_sampler(dev, format)) + return false; + + if ((bindings & PIPE_BIND_VERTEX_BUFFER) && + !ilo_format_support_vb(dev, format)) + return false; + + return true; +} + +static boolean +ilo_is_video_format_supported(struct pipe_screen *screen, + enum pipe_format format, + enum pipe_video_profile profile, + enum pipe_video_entrypoint entrypoint) +{ + return vl_video_buffer_is_format_supported(screen, format, profile, entrypoint); +} + static void ilo_screen_fence_reference(struct pipe_screen *screen, struct pipe_fence_handle **ptr, @@ -686,6 +731,9 @@ ilo_screen_create(struct intel_winsys *ws) is->base.get_timestamp = ilo_get_timestamp; + is->base.is_format_supported = ilo_is_format_supported; + is->base.is_video_format_supported = ilo_is_video_format_supported; + is->base.flush_frontbuffer = NULL; is->base.fence_reference = ilo_screen_fence_reference; @@ -694,7 +742,6 @@ ilo_screen_create(struct intel_winsys *ws) is->base.get_driver_query_info = NULL; - ilo_init_format_functions(is); ilo_init_context_functions(is); ilo_init_resource_functions(is); diff --git a/src/gallium/drivers/ilo/ilo_state_3d_bottom.c b/src/gallium/drivers/ilo/ilo_state_3d_bottom.c index 5ba72ae6726..daf6cb19e63 100644 --- a/src/gallium/drivers/ilo/ilo_state_3d_bottom.c +++ b/src/gallium/drivers/ilo/ilo_state_3d_bottom.c @@ -26,12 +26,12 @@ */ #include "genhw/genhw.h" +#include "core/ilo_format.h" #include "util/u_dual_blend.h" #include "util/u_framebuffer.h" #include "util/u_half.h" #include "ilo_context.h" -#include "ilo_format.h" #include "ilo_resource.h" #include "ilo_shader.h" #include "ilo_state.h" @@ -2162,8 +2162,8 @@ fb_set_blend_caps(const struct ilo_dev *dev, caps->can_alpha_test = !util_format_is_pure_integer(format); caps->dst_alpha_forced_one = - (ilo_translate_render_format(dev, format) != - ilo_translate_color_format(dev, format)); + (ilo_format_translate_render(dev, format) != + ilo_format_translate_color(dev, format)); /* sanity check */ if (caps->dst_alpha_forced_one) { @@ -2178,8 +2178,8 @@ fb_set_blend_caps(const struct ilo_dev *dev, break; } - assert(ilo_translate_render_format(dev, format) == - ilo_translate_color_format(dev, render_format)); + assert(ilo_format_translate_render(dev, format) == + ilo_format_translate_color(dev, render_format)); } } diff --git a/src/gallium/drivers/ilo/ilo_state_3d_top.c b/src/gallium/drivers/ilo/ilo_state_3d_top.c index 9cfd821c1f3..167c0911a46 100644 --- a/src/gallium/drivers/ilo/ilo_state_3d_top.c +++ b/src/gallium/drivers/ilo/ilo_state_3d_top.c @@ -26,13 +26,13 @@ */ #include "genhw/genhw.h" +#include "core/ilo_format.h" #include "util/u_dual_blend.h" #include "util/u_framebuffer.h" #include "util/u_half.h" #include "util/u_resource.h" #include "ilo_context.h" -#include "ilo_format.h" #include "ilo_resource.h" #include "ilo_shader.h" #include "ilo_state.h" @@ -62,7 +62,7 @@ ve_init_cso(const struct ilo_dev *dev, GEN6_VFCOMP_STORE_1_FP; } - format = ilo_translate_vertex_format(dev, state->src_format); + format = ilo_format_translate_vertex(dev, state->src_format); STATIC_ASSERT(Elements(cso->payload) >= 2); cso->payload[0] = @@ -485,7 +485,7 @@ view_init_for_buffer_gen6(const struct ilo_dev *dev, * structure in a buffer. */ - surface_format = ilo_translate_color_format(dev, elem_format); + surface_format = ilo_format_translate_color(dev, elem_format); num_entries = size / struct_size; /* see if there is enough space to fit another element */ @@ -579,9 +579,9 @@ view_init_for_texture_gen6(const struct ilo_dev *dev, format = PIPE_FORMAT_Z32_FLOAT; if (is_rt) - surface_format = ilo_translate_render_format(dev, format); + surface_format = ilo_format_translate_render(dev, format); else - surface_format = ilo_translate_texture_format(dev, format); + surface_format = ilo_format_translate_texture(dev, format); assert(surface_format >= 0); width = tex->layout.width0; @@ -812,7 +812,7 @@ view_init_for_buffer_gen7(const struct ilo_dev *dev, surface_type = (structured) ? GEN7_SURFTYPE_STRBUF : GEN6_SURFTYPE_BUFFER; surface_format = (typed) ? - ilo_translate_color_format(dev, elem_format) : GEN6_FORMAT_RAW; + ilo_format_translate_color(dev, elem_format) : GEN6_FORMAT_RAW; num_entries = size / struct_size; /* see if there is enough space to fit another element */ @@ -941,9 +941,9 @@ view_init_for_texture_gen7(const struct ilo_dev *dev, format = PIPE_FORMAT_Z32_FLOAT; if (is_rt) - surface_format = ilo_translate_render_format(dev, format); + surface_format = ilo_format_translate_render(dev, format); else - surface_format = ilo_translate_texture_format(dev, format); + surface_format = ilo_format_translate_texture(dev, format); assert(surface_format >= 0); width = tex->layout.width0; |