panfrost/decode: Remove memory comments
[mesa.git] / src / gallium / drivers / panfrost / pan_context.h
index 89f821318e1c590d3f7f3d35f76a6719814783d6..d0365310223b0c5c19fb9662c8dada810325c114 100644 (file)
 #ifndef __BUILDER_H__
 #define __BUILDER_H__
 
-#define MFBD
-
 #define _LARGEFILE64_SOURCE 1
 #define CACHE_LINE_SIZE 1024 /* TODO */
 #include <sys/mman.h>
 #include <assert.h>
 #include "pan_resource.h"
+#include "pan_job.h"
 
 #include "pipe/p_compiler.h"
 #include "pipe/p_config.h"
 #include "pipe/p_screen.h"
 #include "pipe/p_state.h"
 #include "util/u_blitter.h"
+#include "util/hash_table.h"
+
+#include "midgard/midgard_compile.h"
 
 /* Forward declare to avoid extra header dep */
 struct prim_convert_context;
 
-/* TODO: Handle on newer hardware */
-#ifdef MFBD
-#define PANFROST_DEFAULT_FBD (MALI_MFBD)
-#define PANFROST_FRAMEBUFFER struct bifrost_framebuffer
-#else
-#define PANFROST_DEFAULT_FBD (MALI_SFBD)
-#define PANFROST_FRAMEBUFFER struct mali_single_framebuffer
-#endif
-
 #define MAX_DRAW_CALLS 4096
 #define MAX_VARYINGS   4096
 
@@ -68,6 +61,12 @@ struct prim_convert_context;
 #define PAN_DIRTY_SAMPLERS   (1 << 8)
 #define PAN_DIRTY_TEXTURES   (1 << 9)
 
+#define SET_BIT(lval, bit, cond) \
+       if (cond) \
+               lval |= (bit); \
+       else \
+               lval &= ~(bit);
+
 struct panfrost_constant_buffer {
         bool dirty;
         size_t size;
@@ -83,6 +82,11 @@ struct panfrost_query {
         struct panfrost_transfer transfer;
 };
 
+struct panfrost_fence {
+        struct pipe_reference reference;
+        int fd;
+};
+
 #define PANFROST_MAX_TRANSIENT_ENTRIES 64
 
 struct panfrost_transient_pool {
@@ -106,6 +110,13 @@ struct panfrost_context {
         /* Gallium context */
         struct pipe_context base;
 
+        /* Bound job and map of panfrost_job_key to jobs */
+        struct panfrost_job *job;
+        struct hash_table *jobs;
+
+        /* panfrost_resource -> panfrost_job */
+        struct hash_table *write_jobs;
+
         /* Bit mask for supported PIPE_DRAW for this hardware */
         unsigned draw_modes;
 
@@ -122,34 +133,12 @@ struct panfrost_context {
         struct panfrost_memory scratchpad;
         struct panfrost_memory tiler_heap;
         struct panfrost_memory varying_mem;
-        struct panfrost_memory misc_0;
-        struct panfrost_memory misc_1;
+        struct panfrost_memory tiler_polygon_list;
+        struct panfrost_memory tiler_dummy;
         struct panfrost_memory depth_stencil_buffer;
 
-        struct {
-                unsigned buffers;
-                const union pipe_color_union *color;
-                double depth;
-                unsigned stencil;
-        } last_clear;
-
         struct panfrost_query *occlusion_query;
 
-        /* Each render job has multiple framebuffer descriptors associated with
-         * it, used for various purposes with more or less the same format. The
-         * most obvious is the fragment framebuffer descriptor, which carries
-         * e.g. clearing information */
-
-#ifdef SFBD
-        struct mali_single_framebuffer fragment_fbd;
-#else
-        struct bifrost_framebuffer fragment_fbd;
-
-        struct bifrost_fb_extra fragment_extra;
-
-        struct bifrost_render_target fragment_rts[4];
-#endif
-
         /* Each draw has corresponding vertex and tiler payloads */
         struct midgard_payload_vertex_tiler payload_vertex;
         struct midgard_payload_vertex_tiler payload_tiler;
@@ -180,17 +169,14 @@ struct panfrost_context {
         /* Per-draw Dirty flags are setup like any other driver */
         int dirty;
 
-        /* Per frame dirty flag - whether there was a clear. If not, we need to do a partial update, maybe */
-        bool frame_cleared;
-
         unsigned vertex_count;
 
         union mali_attr attributes[PIPE_MAX_ATTRIBS];
 
         unsigned varying_height;
 
-        struct mali_viewport *viewport;
-        PANFROST_FRAMEBUFFER vt_framebuffer;
+        struct mali_single_framebuffer vt_framebuffer_sfbd;
+        struct bifrost_framebuffer vt_framebuffer_mfbd;
 
         /* TODO: Multiple uniform buffers (index =/= 0), finer updates? */
 
@@ -204,8 +190,8 @@ struct panfrost_context {
 
         struct panfrost_vertex_state *vertex;
 
-        struct pipe_vertex_buffer *vertex_buffers;
-        unsigned vertex_buffer_count;
+        struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];
+        uint32_t vb_mask;
 
         struct panfrost_sampler_state *samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
         unsigned sampler_count[PIPE_SHADER_TYPES];
@@ -223,6 +209,18 @@ struct panfrost_context {
         struct pipe_blend_color blend_color;
         struct pipe_depth_stencil_alpha_state *depth_stencil;
         struct pipe_stencil_ref stencil_ref;
+
+        /* True for t6XX, false for t8xx. */
+        bool is_t6xx;
+
+        /* If set, we'll require the use of single render-target framebuffer
+         * descriptors (SFBD), for older hardware -- specifically, <T760 hardware, If
+         * false, we'll use the MFBD no matter what. New hardware -does- retain support
+         * for SFBD, and in theory we could flip between them on a per-RT basis, but
+         * there's no real advantage to doing so */
+        bool require_sfbd;
+
+       uint32_t out_sync;
 };
 
 /* Corresponds to the CSO */
@@ -242,33 +240,13 @@ struct panfrost_blend_state {
 
         /* Compiled fixed function command */
         struct mali_blend_equation equation;
+        float constant;
 
         /* Compiled blend shader */
         mali_ptr blend_shader;
         int blend_work_count;
 };
 
-/* Internal varyings descriptor */
-struct panfrost_varyings {
-        /* Varyings information: stride of each chunk of memory used for
-         * varyings (similar structure with attributes). Count is just the
-         * number of vec4's. Buffer count is the number of varying chunks (<=
-         * count). Height is used to calculate gl_Position's position ("it's
-         * not a pun, Alyssa!"). Vertex-only varyings == descriptor for
-         * gl_Position and something else apparently occupying the same space.
-         * Varyings == main varyings descriptors following typical mali_attr
-         * conventions. */
-
-        unsigned varyings_stride[MAX_VARYINGS];
-        unsigned varying_count;
-        unsigned varying_buffer_count;
-
-        /* Map of the actual varyings buffer */
-        uint8_t *varyings_buffer_cpu;
-        mali_ptr varyings_descriptor;
-        mali_ptr varyings_descriptor_fragment;
-};
-
 /* Variants bundle together to form the backing CSO, bundling multiple
  * shaders with varying emulated features baked in (alpha test
  * parameters, etc) */
@@ -287,9 +265,13 @@ struct panfrost_shader_state {
         int uniform_count;
         bool can_discard;
         bool writes_point_size;
+        bool reads_point_coord;
 
-        /* Valid for vertex shaders only due to when this is calculated */
-        struct panfrost_varyings varyings;
+        struct mali_attr_meta varyings[PIPE_MAX_ATTRIBS];
+        gl_varying_slot varyings_loc[PIPE_MAX_ATTRIBS];
+
+        unsigned sysval_count;
+        unsigned sysval[MAX_SYSVAL_COUNT];
 
         /* Information on this particular shader variant */
         struct pipe_alpha_state alpha_state;
@@ -310,11 +292,7 @@ struct panfrost_vertex_state {
         unsigned num_elements;
 
         struct pipe_vertex_element pipe[PIPE_MAX_ATTRIBS];
-        int nr_components[PIPE_MAX_ATTRIBS];
-
-        /* The actual attribute meta, prebaked and GPU mapped. TODO: Free memory */
-        struct mali_attr_meta *hw;
-        mali_ptr descriptor_ptr;
+        struct mali_attr_meta hw[PIPE_MAX_ATTRIBS];
 };
 
 struct panfrost_sampler_state {
@@ -335,12 +313,6 @@ pan_context(struct pipe_context *pcontext)
         return (struct panfrost_context *) pcontext;
 }
 
-static inline struct panfrost_screen *
-pan_screen(struct pipe_screen *p)
-{
-   return (struct panfrost_screen *)p;
-}
-
 struct pipe_context *
 panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags);
 
@@ -348,7 +320,7 @@ void
 panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data);
 
 struct panfrost_transfer
-panfrost_vertex_tiler_job(struct panfrost_context *ctx, bool is_tiler, bool is_elided_tiler);
+panfrost_vertex_tiler_job(struct panfrost_context *ctx, bool is_tiler);
 
 unsigned
 panfrost_get_default_swizzle(unsigned components);
@@ -359,8 +331,20 @@ panfrost_flush(
         struct pipe_fence_handle **fence,
         unsigned flags);
 
+bool
+panfrost_is_scanout(struct panfrost_context *ctx);
+
+mali_ptr panfrost_sfbd_fragment(struct panfrost_context *ctx, bool has_draws);
+mali_ptr panfrost_mfbd_fragment(struct panfrost_context *ctx, bool has_draws);
+
+struct bifrost_framebuffer
+panfrost_emit_mfbd(struct panfrost_context *ctx, unsigned vertex_count);
+
+struct mali_single_framebuffer
+panfrost_emit_sfbd(struct panfrost_context *ctx, unsigned vertex_count);
+
 mali_ptr
-panfrost_fragment_job(struct panfrost_context *ctx);
+panfrost_fragment_job(struct panfrost_context *ctx, bool has_draws);
 
 void
 panfrost_shader_compile(struct panfrost_context *ctx, struct mali_shader_meta *meta, const char *src, int type, struct panfrost_shader_state *state);