diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2017-12-31 06:33:44 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2017-12-31 06:33:44 +0000 |
commit | b90fb74e3c85f2799d21d1e07bf91c5fb8359eb8 (patch) | |
tree | 385895e8835e6989d7730ee516b433eb41826885 /lib/mesa/src/gallium/drivers/vc4 | |
parent | d9c6ca3ea74f178cbd2d5f0fb0bc14843854fd0f (diff) |
Import Mesa 17.2.8
Diffstat (limited to 'lib/mesa/src/gallium/drivers/vc4')
-rw-r--r-- | lib/mesa/src/gallium/drivers/vc4/vc4_cl.h | 115 | ||||
-rw-r--r-- | lib/mesa/src/gallium/drivers/vc4/vc4_cl_dump.c | 53 | ||||
-rw-r--r-- | lib/mesa/src/gallium/drivers/vc4/vc4_cl_dump.h | 30 | ||||
-rw-r--r-- | lib/mesa/src/gallium/drivers/vc4/vc4_job.c | 16 | ||||
-rw-r--r-- | lib/mesa/src/gallium/drivers/vc4/vc4_resource.h | 22 | ||||
-rw-r--r-- | lib/mesa/src/gallium/drivers/vc4/vc4_tiling_lt_neon.c | 30 | ||||
-rw-r--r-- | lib/mesa/src/gallium/drivers/vc4/vc4_uniforms.c | 2 |
7 files changed, 217 insertions, 51 deletions
diff --git a/lib/mesa/src/gallium/drivers/vc4/vc4_cl.h b/lib/mesa/src/gallium/drivers/vc4/vc4_cl.h index 74bf8cfca..8df9dbfe6 100644 --- a/lib/mesa/src/gallium/drivers/vc4/vc4_cl.h +++ b/lib/mesa/src/gallium/drivers/vc4/vc4_cl.h @@ -29,10 +29,9 @@ #include "util/u_math.h" #include "util/macros.h" -#include "kernel/vc4_packet.h" - struct vc4_bo; struct vc4_job; +struct vc4_cl; /** * Undefined structure, used for typechecking that you're passing the pointers @@ -40,19 +39,35 @@ struct vc4_job; */ struct vc4_cl_out; +/** A reference to a BO used in the CL packing functions */ +struct vc4_cl_reloc { + struct vc4_bo *bo; + uint32_t offset; +}; + +static inline void cl_pack_emit_reloc(struct vc4_cl *cl, const struct vc4_cl_reloc *); + +#define __gen_user_data struct vc4_cl +#define __gen_address_type struct vc4_cl_reloc +#define __gen_address_offset(reloc) ((reloc)->offset) +#define __gen_emit_reloc cl_pack_emit_reloc + +#include "kernel/vc4_packet.h" +#include "broadcom/cle/v3d_packet_v21_pack.h" + struct vc4_cl { void *base; + struct vc4_job *job; struct vc4_cl_out *next; struct vc4_cl_out *reloc_next; uint32_t size; -#ifdef DEBUG +#ifndef NDEBUG uint32_t reloc_count; #endif }; -void vc4_init_cl(void *mem_ctx, struct vc4_cl *cl); +void vc4_init_cl(struct vc4_job *job, struct vc4_cl *cl); void vc4_reset_cl(struct vc4_cl *cl); -void vc4_dump_cl(void *cl, uint32_t size, bool is_render); uint32_t vc4_gem_hindex(struct vc4_job *job, struct vc4_bo *bo); struct PACKED unaligned_16 { uint16_t x; }; @@ -148,8 +163,8 @@ static inline void cl_start_reloc(struct vc4_cl *cl, struct vc4_cl_out **out, uint32_t n) { assert(n == 1 || n == 2); -#ifdef DEBUG assert(cl->reloc_count == 0); +#ifndef NDEBUG cl->reloc_count = n; #endif @@ -162,8 +177,8 @@ cl_start_reloc(struct vc4_cl *cl, struct vc4_cl_out **out, uint32_t n) static inline struct vc4_cl_out * cl_start_shader_reloc(struct vc4_cl *cl, uint32_t n) { -#ifdef DEBUG assert(cl->reloc_count == 0); +#ifndef NDEBUG cl->reloc_count = n; #endif cl->reloc_next = cl->next; @@ -181,7 +196,7 @@ cl_reloc(struct vc4_job *job, struct vc4_cl *cl, struct vc4_cl_out **cl_out, *(uint32_t *)cl->reloc_next = vc4_gem_hindex(job, bo); cl_advance(&cl->reloc_next, 4); -#ifdef DEBUG +#ifndef NDEBUG cl->reloc_count--; #endif @@ -196,13 +211,95 @@ cl_aligned_reloc(struct vc4_job *job, struct vc4_cl *cl, *(uint32_t *)cl->reloc_next = vc4_gem_hindex(job, bo); cl_advance(&cl->reloc_next, 4); -#ifdef DEBUG +#ifndef NDEBUG cl->reloc_count--; #endif cl_aligned_u32(cl_out, offset); } +/** + * Reference to a BO with its associated offset, used in the pack process. + */ +static inline struct vc4_cl_reloc +cl_address(struct vc4_bo *bo, uint32_t offset) +{ + struct vc4_cl_reloc reloc = { + .bo = bo, + .offset = offset, + }; + return reloc; +} + void cl_ensure_space(struct vc4_cl *cl, uint32_t size); +#define cl_packet_header(packet) V3D21_ ## packet ## _header +#define cl_packet_length(packet) V3D21_ ## packet ## _length +#define cl_packet_pack(packet) V3D21_ ## packet ## _pack +#define cl_packet_struct(packet) V3D21_ ## packet + +static inline void * +cl_get_emit_space(struct vc4_cl_out **cl, size_t size) +{ + void *addr = *cl; + cl_advance(cl, size); + return addr; +} + +/* Macro for setting up an emit of a CL struct. A temporary unpacked struct + * is created, which you get to set fields in of the form: + * + * cl_emit(bcl, FLAT_SHADE_FLAGS, flags) { + * .flags.flat_shade_flags = 1 << 2, + * } + * + * or default values only can be emitted with just: + * + * cl_emit(bcl, FLAT_SHADE_FLAGS, flags); + * + * The trick here is that we make a for loop that will execute the body + * (either the block or the ';' after the macro invocation) exactly once. + * Also, *dst is actually of the wrong type, it's the + * uint8_t[cl_packet_length()] in the CL, not a cl_packet_struct(packet). + */ +#define cl_emit(cl, packet, name) \ + for (struct cl_packet_struct(packet) name = { \ + cl_packet_header(packet) \ + }, \ + *_loop_terminate = &name; \ + __builtin_expect(_loop_terminate != NULL, 1); \ + ({ \ + struct vc4_cl_out *cl_out = cl_start(cl); \ + cl_packet_pack(packet)(cl, (uint8_t *)cl_out, &name); \ + VG(VALGRIND_CHECK_MEM_IS_DEFINED(cl_out, \ + cl_packet_length(packet))); \ + cl_advance(&cl_out, cl_packet_length(packet)); \ + cl_end(cl, cl_out); \ + _loop_terminate = NULL; \ + })) \ + +#define cl_emit_prepacked(cl, packet) do { \ + memcpy((cl)->next, packet, sizeof(*packet)); \ + cl_advance(&(cl)->next, sizeof(*packet)); \ +} while (0) + +/** + * Helper function called by the XML-generated pack functions for filling in + * an address field in shader records. + * + * Relocations for shader recs and texturing involve the packet (or uniforms + * stream) being preceded by the handles to the BOs, and the offset within the + * BO being in the stream (the output of this function). + */ +static inline void +cl_pack_emit_reloc(struct vc4_cl *cl, const struct vc4_cl_reloc *reloc) +{ + *(uint32_t *)cl->reloc_next = vc4_gem_hindex(cl->job, reloc->bo); + cl_advance(&cl->reloc_next, 4); + +#ifndef NDEBUG + cl->reloc_count--; +#endif +} + #endif /* VC4_CL_H */ diff --git a/lib/mesa/src/gallium/drivers/vc4/vc4_cl_dump.c b/lib/mesa/src/gallium/drivers/vc4/vc4_cl_dump.c index a719f276b..b14cf387d 100644 --- a/lib/mesa/src/gallium/drivers/vc4/vc4_cl_dump.c +++ b/lib/mesa/src/gallium/drivers/vc4/vc4_cl_dump.c @@ -24,7 +24,16 @@ #include "util/u_math.h" #include "util/u_prim.h" #include "util/macros.h" -#include "vc4_context.h" +#include "vc4_cl_dump.h" +#include "kernel/vc4_packet.h" + +#define __gen_user_data void +#define __gen_address_type uint32_t +#define __gen_address_offset(reloc) (*reloc) +#define __gen_emit_reloc(cl, reloc) +#define __gen_unpack_address __gen_unpack_uint + +#include "broadcom/cle/v3d_packet_v21_pack.h" #define dump_VC4_PACKET_LINE_WIDTH dump_float #define dump_VC4_PACKET_POINT_SIZE dump_float @@ -187,15 +196,16 @@ static void dump_VC4_PACKET_GL_ARRAY_PRIMITIVE(void *cl, uint32_t offset, uint32_t hw_offset) { uint8_t *b = cl + offset; - uint32_t *count = cl + offset + 1; - uint32_t *start = cl + offset + 5; + + struct V3D21_VERTEX_ARRAY_PRIMITIVES values; + V3D21_VERTEX_ARRAY_PRIMITIVES_unpack(cl + offset - 1, &values); fprintf(stderr, "0x%08x 0x%08x: 0x%02x %s\n", - offset, hw_offset, b[0], u_prim_name(b[0] & 0x7)); + offset, hw_offset, b[0], u_prim_name(values.primitive_mode)); fprintf(stderr, "0x%08x 0x%08x: %d verts\n", - offset + 1, hw_offset + 1, *count); + offset + 1, hw_offset + 1, values.length); fprintf(stderr, "0x%08x 0x%08x: 0x%08x start\n", - offset + 5, hw_offset + 5, *start); + offset + 5, hw_offset + 5, values.index_of_first_vertex); } static void @@ -223,10 +233,15 @@ dump_VC4_PACKET_CLIPPER_XY_SCALING(void *cl, uint32_t offset, uint32_t hw_offset { uint32_t *scale = cl + offset; + struct V3D21_CLIPPER_XY_SCALING values; + V3D21_CLIPPER_XY_SCALING_unpack(cl + offset - 1, &values); + fprintf(stderr, "0x%08x 0x%08x: %f, %f (%f, %f, 0x%08x, 0x%08x)\n", offset, hw_offset, - uif(scale[0]) / 16.0, uif(scale[1]) / 16.0, - uif(scale[0]), uif(scale[1]), + values.viewport_half_width_in_1_16th_of_pixel / 16.0, + values.viewport_half_height_in_1_16th_of_pixel / 16.0, + values.viewport_half_width_in_1_16th_of_pixel, + values.viewport_half_height_in_1_16th_of_pixel, scale[0], scale[1]); } @@ -236,9 +251,13 @@ dump_VC4_PACKET_CLIPPER_Z_SCALING(void *cl, uint32_t offset, uint32_t hw_offset) uint32_t *translate = cl + offset; uint32_t *scale = cl + offset + 8; + struct V3D21_CLIPPER_Z_SCALE_AND_OFFSET values; + V3D21_CLIPPER_Z_SCALE_AND_OFFSET_unpack(cl + offset - 1, &values); + fprintf(stderr, "0x%08x 0x%08x: %f, %f (0x%08x, 0x%08x)\n", offset, hw_offset, - uif(translate[0]), uif(translate[1]), + values.viewport_z_scale_zc_to_zs, + values.viewport_z_offset_zc_to_zs, translate[0], translate[1]); fprintf(stderr, "0x%08x 0x%08x: %f, %f (0x%08x, 0x%08x)\n", @@ -250,28 +269,26 @@ dump_VC4_PACKET_CLIPPER_Z_SCALING(void *cl, uint32_t offset, uint32_t hw_offset) static void dump_VC4_PACKET_TILE_BINNING_MODE_CONFIG(void *cl, uint32_t offset, uint32_t hw_offset) { - uint32_t *tile_alloc_addr = cl + offset; - uint32_t *tile_alloc_size = cl + offset + 4; - uint32_t *tile_state_addr = cl + offset + 8; - uint8_t *bin_x = cl + offset + 12; - uint8_t *bin_y = cl + offset + 13; uint8_t *flags = cl + offset + 14; + struct V3D21_TILE_BINNING_MODE_CONFIGURATION values; + V3D21_TILE_BINNING_MODE_CONFIGURATION_unpack(cl + offset - 1, &values); + fprintf(stderr, "0x%08x 0x%08x: tile alloc addr 0x%08x\n", offset, hw_offset, - *tile_alloc_addr); + values.tile_allocation_memory_address); fprintf(stderr, "0x%08x 0x%08x: tile alloc size %db\n", offset + 4, hw_offset + 4, - *tile_alloc_size); + values.tile_allocation_memory_size); fprintf(stderr, "0x%08x 0x%08x: tile state addr 0x%08x\n", offset + 8, hw_offset + 8, - *tile_state_addr); + values.tile_state_data_array_address); fprintf(stderr, "0x%08x 0x%08x: tiles (%d, %d)\n", offset + 12, hw_offset + 12, - *bin_x, *bin_y); + values.width_in_tiles, values.height_in_tiles); fprintf(stderr, "0x%08x 0x%08x: flags 0x%02x\n", offset + 14, hw_offset + 14, diff --git a/lib/mesa/src/gallium/drivers/vc4/vc4_cl_dump.h b/lib/mesa/src/gallium/drivers/vc4/vc4_cl_dump.h new file mode 100644 index 000000000..760ab8da7 --- /dev/null +++ b/lib/mesa/src/gallium/drivers/vc4/vc4_cl_dump.h @@ -0,0 +1,30 @@ +/* + * Copyright © 2016 Broadcom + * + * 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 (including the next + * paragraph) 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. + */ + +#ifndef VC4_CL_DUMP_H +#define VC4_CL_DUMP_H + +#include <stdbool.h> +void vc4_dump_cl(void *cl, uint32_t size, bool is_render); + +#endif diff --git a/lib/mesa/src/gallium/drivers/vc4/vc4_job.c b/lib/mesa/src/gallium/drivers/vc4/vc4_job.c index d39472ef1..6a1d1a4ce 100644 --- a/lib/mesa/src/gallium/drivers/vc4/vc4_job.c +++ b/lib/mesa/src/gallium/drivers/vc4/vc4_job.c @@ -27,6 +27,7 @@ */ #include <xf86drm.h> +#include "vc4_cl_dump.h" #include "vc4_context.h" #include "util/hash_table.h" @@ -117,12 +118,17 @@ vc4_flush_jobs_reading_resource(struct vc4_context *vc4, struct vc4_job *job = entry->data; struct vc4_bo **referenced_bos = job->bo_pointers.base; + bool found = false; for (int i = 0; i < cl_offset(&job->bo_handles) / 4; i++) { if (referenced_bos[i] == rsc->bo) { - vc4_job_submit(vc4, job); - continue; + found = true; + break; } } + if (found) { + vc4_job_submit(vc4, job); + continue; + } /* Also check for the Z/color buffers, since the references to * those are only added immediately before submit. @@ -377,13 +383,11 @@ vc4_job_submit(struct vc4_context *vc4, struct vc4_job *job) * until the FLUSH completes. */ cl_ensure_space(&job->bcl, 8); - struct vc4_cl_out *bcl = cl_start(&job->bcl); - cl_u8(&bcl, VC4_PACKET_INCREMENT_SEMAPHORE); + cl_emit(&job->bcl, INCREMENT_SEMAPHORE, incr); /* The FLUSH caps all of our bin lists with a * VC4_PACKET_RETURN. */ - cl_u8(&bcl, VC4_PACKET_FLUSH); - cl_end(&job->bcl, bcl); + cl_emit(&job->bcl, FLUSH, flush); } struct drm_vc4_submit_cl submit = { .color_read.hindex = ~0, diff --git a/lib/mesa/src/gallium/drivers/vc4/vc4_resource.h b/lib/mesa/src/gallium/drivers/vc4/vc4_resource.h index 27aa4e872..d4c491e50 100644 --- a/lib/mesa/src/gallium/drivers/vc4/vc4_resource.h +++ b/lib/mesa/src/gallium/drivers/vc4/vc4_resource.h @@ -52,8 +52,9 @@ struct vc4_surface { }; struct vc4_resource { - struct u_resource base; + struct pipe_resource base; struct vc4_bo *bo; + struct renderonly_scanout *scanout; struct vc4_resource_slice slices[VC4_MAX_MIP_LEVELS]; uint32_t cube_map_stride; int cpp; @@ -80,20 +81,6 @@ struct vc4_resource { * buffer) may get marked. */ uint32_t initialized_buffers; - - /** - * Resource containing the non-GL_TEXTURE_BASE_LEVEL-rebased texture - * contents, or the 4-byte index buffer. - * - * If the parent is set for an texture, then this resource is actually - * the texture contents just starting from the sampler_view's - * first_level. - * - * If the parent is set for an index index buffer, then this resource - * is actually a shadow containing a 2-byte index buffer starting from - * the ib's offset. - */ - struct pipe_resource *shadow_parent; }; static inline struct vc4_resource * @@ -121,9 +108,10 @@ struct pipe_resource *vc4_resource_create(struct pipe_screen *pscreen, void vc4_update_shadow_baselevel_texture(struct pipe_context *pctx, struct pipe_sampler_view *view); struct pipe_resource *vc4_get_shadow_index_buffer(struct pipe_context *pctx, - const struct pipe_index_buffer *ib, + const struct pipe_draw_info *info, + uint32_t offset, uint32_t count, - uint32_t *offset); + uint32_t *shadow_offset); void vc4_dump_surface(struct pipe_surface *psurf); #endif /* VC4_RESOURCE_H */ diff --git a/lib/mesa/src/gallium/drivers/vc4/vc4_tiling_lt_neon.c b/lib/mesa/src/gallium/drivers/vc4/vc4_tiling_lt_neon.c new file mode 100644 index 000000000..7ba66ae4c --- /dev/null +++ b/lib/mesa/src/gallium/drivers/vc4/vc4_tiling_lt_neon.c @@ -0,0 +1,30 @@ +/* + * Copyright © 2017 Broadcom + * + * 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 (including the next + * paragraph) 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. + */ + +/* Wrapper file for building vc4_tiling_lt.c with the "build NEON assembly if + * possible" flag set, since Android.mk doesn't have a way to set CFLAGS for a + * single file. + */ + +#define VC4_BUILD_NEON +#include "vc4_tiling_lt.c" diff --git a/lib/mesa/src/gallium/drivers/vc4/vc4_uniforms.c b/lib/mesa/src/gallium/drivers/vc4/vc4_uniforms.c index 07781b852..b8169347f 100644 --- a/lib/mesa/src/gallium/drivers/vc4/vc4_uniforms.c +++ b/lib/mesa/src/gallium/drivers/vc4/vc4_uniforms.c @@ -35,7 +35,7 @@ write_texture_p0(struct vc4_job *job, { struct vc4_sampler_view *sview = vc4_sampler_view(texstate->textures[unit]); - struct vc4_resource *rsc = vc4_resource(sview->base.texture); + struct vc4_resource *rsc = vc4_resource(sview->texture); cl_reloc(job, &job->uniforms, uniforms, rsc->bo, sview->texture_p0); } |