diff options
-rw-r--r-- | src/gallium/drivers/ilo/Makefile.sources | 2 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_blit.c | 104 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_blitter.c | 74 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_blitter.h | 80 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_blitter_pipe.c | 196 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_context.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/ilo_context.h | 4 |
7 files changed, 363 insertions, 103 deletions
diff --git a/src/gallium/drivers/ilo/Makefile.sources b/src/gallium/drivers/ilo/Makefile.sources index 0a1cc85c58e..363ae172f18 100644 --- a/src/gallium/drivers/ilo/Makefile.sources +++ b/src/gallium/drivers/ilo/Makefile.sources @@ -5,6 +5,8 @@ C_SOURCES := \ ilo_3d_pipeline_gen6.c \ ilo_3d_pipeline_gen7.c \ ilo_blit.c \ + ilo_blitter.c \ + ilo_blitter_pipe.c \ ilo_context.c \ ilo_cp.c \ ilo_format.c \ diff --git a/src/gallium/drivers/ilo/ilo_blit.c b/src/gallium/drivers/ilo/ilo_blit.c index 147dbe47938..3c1695950eb 100644 --- a/src/gallium/drivers/ilo/ilo_blit.c +++ b/src/gallium/drivers/ilo/ilo_blit.c @@ -25,12 +25,11 @@ * Chia-I Wu <[email protected]> */ -#include "util/u_blitter.h" -#include "util/u_clear.h" #include "util/u_pack_color.h" #include "util/u_surface.h" #include "intel_reg.h" +#include "ilo_blitter.h" #include "ilo_context.h" #include "ilo_cp.h" #include "ilo_resource.h" @@ -532,62 +531,6 @@ blitter_xy_color_blt(struct pipe_context *pipe, return true; } -enum ilo_blitter_op { - ILO_BLITTER_CLEAR, - ILO_BLITTER_CLEAR_SURFACE, - ILO_BLITTER_BLIT, -}; - -static void -ilo_blitter_begin(struct ilo_context *ilo, enum ilo_blitter_op op) -{ - /* as documented in util/u_blitter.h */ - util_blitter_save_vertex_buffer_slot(ilo->blitter, ilo->vb.states); - util_blitter_save_vertex_elements(ilo->blitter, (void *) ilo->ve); - util_blitter_save_vertex_shader(ilo->blitter, ilo->vs); - util_blitter_save_geometry_shader(ilo->blitter, ilo->gs); - util_blitter_save_so_targets(ilo->blitter, ilo->so.count, ilo->so.states); - - util_blitter_save_fragment_shader(ilo->blitter, ilo->fs); - util_blitter_save_depth_stencil_alpha(ilo->blitter, (void *) ilo->dsa); - util_blitter_save_blend(ilo->blitter, (void *) ilo->blend); - - /* undocumented? */ - util_blitter_save_viewport(ilo->blitter, &ilo->viewport.viewport0); - util_blitter_save_stencil_ref(ilo->blitter, &ilo->stencil_ref); - util_blitter_save_sample_mask(ilo->blitter, ilo->sample_mask); - - switch (op) { - case ILO_BLITTER_CLEAR: - util_blitter_save_rasterizer(ilo->blitter, (void *) ilo->rasterizer); - break; - case ILO_BLITTER_CLEAR_SURFACE: - util_blitter_save_framebuffer(ilo->blitter, &ilo->fb.state); - break; - case ILO_BLITTER_BLIT: - util_blitter_save_rasterizer(ilo->blitter, (void *) ilo->rasterizer); - util_blitter_save_framebuffer(ilo->blitter, &ilo->fb.state); - - util_blitter_save_fragment_sampler_states(ilo->blitter, - ilo->sampler[PIPE_SHADER_FRAGMENT].count, - (void **) ilo->sampler[PIPE_SHADER_FRAGMENT].cso); - - util_blitter_save_fragment_sampler_views(ilo->blitter, - ilo->view[PIPE_SHADER_FRAGMENT].count, - ilo->view[PIPE_SHADER_FRAGMENT].states); - - /* disable render condition? */ - break; - default: - break; - } -} - -static void -ilo_blitter_end(struct ilo_context *ilo) -{ -} - static void ilo_clear(struct pipe_context *pipe, unsigned buffers, @@ -597,14 +540,7 @@ ilo_clear(struct pipe_context *pipe, { struct ilo_context *ilo = ilo_context(pipe); - /* TODO we should pause/resume some queries */ - ilo_blitter_begin(ilo, ILO_BLITTER_CLEAR); - - util_blitter_clear(ilo->blitter, - ilo->fb.state.width, ilo->fb.state.height, - buffers, color, depth, stencil); - - ilo_blitter_end(ilo); + ilo_blitter_pipe_clear_fb(ilo->blitter, buffers, color, depth, stencil); } static void @@ -634,10 +570,8 @@ ilo_clear_render_target(struct pipe_context *pipe, packed.ui)) return; - ilo_blitter_begin(ilo, ILO_BLITTER_CLEAR_SURFACE); - util_blitter_clear_render_target(ilo->blitter, + ilo_blitter_pipe_clear_rt(ilo->blitter, dst, color, dstx, dsty, width, height); - ilo_blitter_end(ilo); } static void @@ -656,43 +590,17 @@ ilo_clear_depth_stencil(struct pipe_context *pipe, * not tell us how to program it. Since depth buffers are always Y-tiled, * HW blit will not work. */ - ilo_blitter_begin(ilo, ILO_BLITTER_CLEAR_SURFACE); - util_blitter_clear_depth_stencil(ilo->blitter, + + ilo_blitter_pipe_clear_zs(ilo->blitter, dst, clear_flags, depth, stencil, dstx, dsty, width, height); - ilo_blitter_end(ilo); } static void ilo_blit(struct pipe_context *pipe, const struct pipe_blit_info *info) { struct ilo_context *ilo = ilo_context(pipe); - struct pipe_blit_info skip_stencil; - - if (util_try_blit_via_copy_region(pipe, info)) - return; - - if (!util_blitter_is_blit_supported(ilo->blitter, info)) { - /* try without stencil */ - if (info->mask & PIPE_MASK_S) { - skip_stencil = *info; - skip_stencil.mask = info->mask & ~PIPE_MASK_S; - - if (util_blitter_is_blit_supported(ilo->blitter, &skip_stencil)) - info = &skip_stencil; - } - - if (info == &skip_stencil) { - ilo_warn("ignore stencil buffer blitting\n"); - } - else { - ilo_warn("failed to blit with the generic blitter\n"); - return; - } - } - ilo_blitter_begin(ilo, ILO_BLITTER_BLIT); - util_blitter_blit(ilo->blitter, info); - ilo_blitter_end(ilo); + ilo_blitter_pipe_blit(ilo->blitter, info); } /** diff --git a/src/gallium/drivers/ilo/ilo_blitter.c b/src/gallium/drivers/ilo/ilo_blitter.c new file mode 100644 index 00000000000..10335920364 --- /dev/null +++ b/src/gallium/drivers/ilo/ilo_blitter.c @@ -0,0 +1,74 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2013 LunarG, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#include "util/u_blitter.h" + +#include "ilo_context.h" +#include "ilo_blitter.h" + +static bool +ilo_blitter_pipe_create(struct ilo_blitter *blitter) +{ + if (blitter->pipe_blitter) + return true; + + blitter->pipe_blitter = util_blitter_create(&blitter->ilo->base); + + return (blitter->pipe_blitter != NULL); +} + +/** + * Create a blitter. Because the use of util_blitter, this must be called + * after the context is initialized. + */ +struct ilo_blitter * +ilo_blitter_create(struct ilo_context *ilo) +{ + struct ilo_blitter *blitter; + + blitter = CALLOC_STRUCT(ilo_blitter); + if (!blitter) + return NULL; + + blitter->ilo = ilo; + + if (!ilo_blitter_pipe_create(blitter)) { + FREE(blitter); + return NULL; + } + + return blitter; +} + +void +ilo_blitter_destroy(struct ilo_blitter *blitter) +{ + if (blitter->pipe_blitter) + util_blitter_destroy(blitter->pipe_blitter); + + FREE(blitter); +} diff --git a/src/gallium/drivers/ilo/ilo_blitter.h b/src/gallium/drivers/ilo/ilo_blitter.h new file mode 100644 index 00000000000..24218f27a62 --- /dev/null +++ b/src/gallium/drivers/ilo/ilo_blitter.h @@ -0,0 +1,80 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2013 LunarG, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#ifndef ILO_BLITTER_H +#define ILO_BLITTER_H + +#include "ilo_common.h" + +struct ilo_context; +struct blitter_context; + +struct ilo_blitter { + struct ilo_context *ilo; + + struct blitter_context *pipe_blitter; +}; + +struct ilo_blitter * +ilo_blitter_create(struct ilo_context *ilo); + +void +ilo_blitter_destroy(struct ilo_blitter *blitter); + +bool +ilo_blitter_pipe_blit(struct ilo_blitter *blitter, + const struct pipe_blit_info *info); + +bool +ilo_blitter_pipe_copy_resource(struct ilo_blitter *blitter, + struct pipe_resource *dst, unsigned dst_level, + unsigned dst_x, unsigned dst_y, unsigned dst_z, + struct pipe_resource *src, unsigned src_level, + const struct pipe_box *src_box); + +bool +ilo_blitter_pipe_clear_rt(struct ilo_blitter *blitter, + struct pipe_surface *rt, + const union pipe_color_union *color, + unsigned x, unsigned y, + unsigned width, unsigned height); + +bool +ilo_blitter_pipe_clear_zs(struct ilo_blitter *blitter, + struct pipe_surface *zs, + unsigned clear_flags, + double depth, unsigned stencil, + unsigned x, unsigned y, + unsigned width, unsigned height); + +bool +ilo_blitter_pipe_clear_fb(struct ilo_blitter *blitter, + unsigned buffers, + const union pipe_color_union *color, + double depth, unsigned stencil); + +#endif /* ILO_BLITTER_H */ diff --git a/src/gallium/drivers/ilo/ilo_blitter_pipe.c b/src/gallium/drivers/ilo/ilo_blitter_pipe.c new file mode 100644 index 00000000000..cfec8b10e5f --- /dev/null +++ b/src/gallium/drivers/ilo/ilo_blitter_pipe.c @@ -0,0 +1,196 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 2013 LunarG, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu <[email protected]> + */ + +#include "util/u_blitter.h" +#include "util/u_surface.h" + +#include "ilo_context.h" +#include "ilo_blitter.h" + +enum ilo_blitter_pipe_op { + ILO_BLITTER_PIPE_BLIT, + ILO_BLITTER_PIPE_COPY, + ILO_BLITTER_PIPE_CLEAR, + ILO_BLITTER_PIPE_CLEAR_FB, +}; + +static void +ilo_blitter_pipe_begin(struct ilo_blitter *blitter, + enum ilo_blitter_pipe_op op) +{ + struct blitter_context *b = blitter->pipe_blitter; + struct ilo_context *ilo = blitter->ilo; + + /* as documented in util/u_blitter.h */ + util_blitter_save_vertex_buffer_slot(b, ilo->vb.states); + util_blitter_save_vertex_elements(b, (void *) ilo->ve); + util_blitter_save_vertex_shader(b, ilo->vs); + util_blitter_save_geometry_shader(b, ilo->gs); + util_blitter_save_so_targets(b, ilo->so.count, ilo->so.states); + + util_blitter_save_fragment_shader(b, ilo->fs); + util_blitter_save_depth_stencil_alpha(b, (void *) ilo->dsa); + util_blitter_save_blend(b, (void *) ilo->blend); + + /* undocumented? */ + util_blitter_save_viewport(b, &ilo->viewport.viewport0); + util_blitter_save_stencil_ref(b, &ilo->stencil_ref); + util_blitter_save_sample_mask(b, ilo->sample_mask); + + switch (op) { + case ILO_BLITTER_PIPE_BLIT: + case ILO_BLITTER_PIPE_COPY: + util_blitter_save_rasterizer(b, (void *) ilo->rasterizer); + util_blitter_save_framebuffer(b, &ilo->fb.state); + + util_blitter_save_fragment_sampler_states(b, + ilo->sampler[PIPE_SHADER_FRAGMENT].count, + (void **) ilo->sampler[PIPE_SHADER_FRAGMENT].cso); + + util_blitter_save_fragment_sampler_views(b, + ilo->view[PIPE_SHADER_FRAGMENT].count, + ilo->view[PIPE_SHADER_FRAGMENT].states); + + /* disable render condition? */ + break; + case ILO_BLITTER_PIPE_CLEAR: + util_blitter_save_rasterizer(b, (void *) ilo->rasterizer); + util_blitter_save_framebuffer(b, &ilo->fb.state); + + /* disable render condition? */ + break; + case ILO_BLITTER_PIPE_CLEAR_FB: + util_blitter_save_rasterizer(b, (void *) ilo->rasterizer); + break; + default: + break; + } +} + +static void +ilo_blitter_pipe_end(struct ilo_blitter *blitter) +{ +} + +bool +ilo_blitter_pipe_blit(struct ilo_blitter *blitter, + const struct pipe_blit_info *info) +{ + struct blitter_context *b = blitter->pipe_blitter; + struct pipe_blit_info skip_stencil; + + if (util_try_blit_via_copy_region(&blitter->ilo->base, info)) + return true; + + if (!util_blitter_is_blit_supported(b, info)) { + /* try without stencil */ + if (info->mask & PIPE_MASK_S) { + skip_stencil = *info; + skip_stencil.mask = info->mask & ~PIPE_MASK_S; + + if (util_blitter_is_blit_supported(blitter->pipe_blitter, + &skip_stencil)) { + ilo_warn("ignore stencil buffer blitting\n"); + info = &skip_stencil; + } + } + + if (info != &skip_stencil) { + ilo_warn("failed to blit with pipe blitter\n"); + return false; + } + } + + ilo_blitter_pipe_begin(blitter, ILO_BLITTER_PIPE_BLIT); + util_blitter_blit(b, info); + ilo_blitter_pipe_end(blitter); + + return true; +} + +bool +ilo_blitter_pipe_copy_resource(struct ilo_blitter *blitter, + struct pipe_resource *dst, unsigned dst_level, + unsigned dst_x, unsigned dst_y, unsigned dst_z, + struct pipe_resource *src, unsigned src_level, + const struct pipe_box *src_box) +{ + return false; +} + +bool +ilo_blitter_pipe_clear_rt(struct ilo_blitter *blitter, + struct pipe_surface *rt, + const union pipe_color_union *color, + unsigned x, unsigned y, + unsigned width, unsigned height) +{ + ilo_blitter_pipe_begin(blitter, ILO_BLITTER_PIPE_CLEAR); + + util_blitter_clear_render_target(blitter->pipe_blitter, + rt, color, x, y, width, height); + + ilo_blitter_pipe_end(blitter); + + return true; +} + +bool +ilo_blitter_pipe_clear_zs(struct ilo_blitter *blitter, + struct pipe_surface *zs, + unsigned clear_flags, + double depth, unsigned stencil, + unsigned x, unsigned y, + unsigned width, unsigned height) +{ + ilo_blitter_pipe_begin(blitter, ILO_BLITTER_PIPE_CLEAR); + + util_blitter_clear_depth_stencil(blitter->pipe_blitter, + zs, clear_flags, depth, stencil, x, y, width, height); + + ilo_blitter_pipe_end(blitter); + + return true; +} + +bool +ilo_blitter_pipe_clear_fb(struct ilo_blitter *blitter, + unsigned buffers, + const union pipe_color_union *color, + double depth, unsigned stencil) +{ + /* TODO we should pause/resume some queries */ + ilo_blitter_pipe_begin(blitter, ILO_BLITTER_PIPE_CLEAR_FB); + + util_blitter_clear(blitter->pipe_blitter, + blitter->ilo->fb.state.width, blitter->ilo->fb.state.height, + buffers, color, depth, stencil); + + ilo_blitter_pipe_end(blitter); + + return true; +} diff --git a/src/gallium/drivers/ilo/ilo_context.c b/src/gallium/drivers/ilo/ilo_context.c index dce1136da96..394081092ec 100644 --- a/src/gallium/drivers/ilo/ilo_context.c +++ b/src/gallium/drivers/ilo/ilo_context.c @@ -25,11 +25,11 @@ * Chia-I Wu <[email protected]> */ -#include "util/u_blitter.h" #include "intel_chipset.h" #include "ilo_3d.h" #include "ilo_blit.h" +#include "ilo_blitter.h" #include "ilo_cp.h" #include "ilo_gpgpu.h" #include "ilo_query.h" @@ -99,7 +99,7 @@ ilo_context_destroy(struct pipe_context *pipe) util_slab_destroy(&ilo->transfer_mempool); if (ilo->blitter) - util_blitter_destroy(ilo->blitter); + ilo_blitter_destroy(ilo->blitter); if (ilo->hw3d) ilo_3d_destroy(ilo->hw3d); if (ilo->shader_cache) @@ -156,7 +156,7 @@ ilo_context_create(struct pipe_screen *screen, void *priv) ilo_init_states(ilo); /* this must be called last as u_blitter is a client of the pipe context */ - ilo->blitter = util_blitter_create(&ilo->base); + ilo->blitter = ilo_blitter_create(ilo); if (!ilo->blitter) { ilo_context_destroy(&ilo->base); return NULL; diff --git a/src/gallium/drivers/ilo/ilo_context.h b/src/gallium/drivers/ilo/ilo_context.h index 02c4c0a8ec1..a37ed001b4c 100644 --- a/src/gallium/drivers/ilo/ilo_context.h +++ b/src/gallium/drivers/ilo/ilo_context.h @@ -34,10 +34,10 @@ #include "ilo_gpe.h" #include "ilo_common.h" -struct blitter_context; struct intel_winsys; struct intel_bo; struct ilo_3d; +struct ilo_blitter; struct ilo_cp; struct ilo_screen; struct ilo_shader_state; @@ -55,7 +55,7 @@ struct ilo_context { struct ilo_shader_cache *shader_cache; struct ilo_3d *hw3d; - struct blitter_context *blitter; + struct ilo_blitter *blitter; uint32_t dirty; |