v3d: don't emit point coordinates varyings if the FS doesn't read them
[mesa.git] / src / gallium / drivers / v3d / v3d_context.h
index 136d85065976e1a88846df083eb538dab0f37d67..225ebe2f5abf0308f3c383f0c3e150f37ad15186 100644 (file)
@@ -36,8 +36,9 @@
 #include "util/bitset.h"
 #include "util/slab.h"
 #include "xf86drm.h"
-#include "v3d_drm.h"
+#include "drm-uapi/v3d_drm.h"
 #include "v3d_screen.h"
+#include "broadcom/common/v3d_limits.h"
 
 struct v3d_job;
 struct v3d_bo;
@@ -87,6 +88,35 @@ void v3d_job_add_bo(struct v3d_job *job, struct v3d_bo *bo);
 
 #define VC5_MAX_FS_INPUTS 64
 
+enum v3d_sampler_state_variant {
+        V3D_SAMPLER_STATE_BORDER_0,
+        V3D_SAMPLER_STATE_F16,
+        V3D_SAMPLER_STATE_F16_UNORM,
+        V3D_SAMPLER_STATE_F16_SNORM,
+        V3D_SAMPLER_STATE_F16_BGRA,
+        V3D_SAMPLER_STATE_F16_BGRA_UNORM,
+        V3D_SAMPLER_STATE_F16_BGRA_SNORM,
+        V3D_SAMPLER_STATE_F16_A,
+        V3D_SAMPLER_STATE_F16_A_SNORM,
+        V3D_SAMPLER_STATE_F16_A_UNORM,
+        V3D_SAMPLER_STATE_F16_LA,
+        V3D_SAMPLER_STATE_F16_LA_UNORM,
+        V3D_SAMPLER_STATE_F16_LA_SNORM,
+        V3D_SAMPLER_STATE_32,
+        V3D_SAMPLER_STATE_32_UNORM,
+        V3D_SAMPLER_STATE_32_SNORM,
+        V3D_SAMPLER_STATE_32_A,
+        V3D_SAMPLER_STATE_32_A_UNORM,
+        V3D_SAMPLER_STATE_32_A_SNORM,
+        V3D_SAMPLER_STATE_1010102U,
+        V3D_SAMPLER_STATE_16U,
+        V3D_SAMPLER_STATE_16I,
+        V3D_SAMPLER_STATE_8I,
+        V3D_SAMPLER_STATE_8U,
+
+        V3D_SAMPLER_STATE_VARIANT_COUNT,
+};
+
 struct v3d_sampler_view {
         struct pipe_sampler_view base;
         uint32_t p0;
@@ -98,6 +128,8 @@ struct v3d_sampler_view {
         /* V3D 4.x: Texture state struct. */
         struct v3d_bo *bo;
 
+        enum v3d_sampler_state_variant sampler_variant;
+
         /* Actual texture to be read by this sampler view.  May be different
          * from base.texture in the case of having a shadow tiled copy of a
          * raster texture.
@@ -113,15 +145,18 @@ struct v3d_sampler_state {
         /* V3D 3.x: Packed texture state. */
         uint8_t texture_shader_state[32];
         /* V3D 4.x: Sampler state struct. */
-        struct v3d_bo *bo;
+        struct pipe_resource *sampler_state;
+        uint32_t sampler_state_offset[V3D_SAMPLER_STATE_VARIANT_COUNT];
+
+        bool border_color_variants;
 };
 
 struct v3d_texture_stateobj {
-        struct pipe_sampler_view *textures[PIPE_MAX_SAMPLERS];
+        struct pipe_sampler_view *textures[V3D_MAX_TEXTURE_SAMPLERS];
         unsigned num_textures;
-        struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS];
+        struct pipe_sampler_state *samplers[V3D_MAX_TEXTURE_SAMPLERS];
         unsigned num_samplers;
-        struct v3d_cl_reloc texture_state[PIPE_MAX_SAMPLERS];
+        struct v3d_cl_reloc texture_state[V3D_MAX_TEXTURE_SAMPLERS];
 };
 
 struct v3d_shader_uniform_info {
@@ -141,13 +176,6 @@ struct v3d_uncompiled_shader {
         uint16_t tf_specs[16];
         uint16_t tf_specs_psiz[16];
         uint32_t num_tf_specs;
-
-        /**
-         * Flag for if the NIR in this shader originally came from TGSI.  If
-         * so, we need to do some fixups at compile time, due to missing
-         * information in TGSI that exists in NIR.
-         */
-        bool was_tgsi;
 };
 
 struct v3d_compiled_shader {
@@ -158,6 +186,7 @@ struct v3d_compiled_shader {
                 struct v3d_prog_data *base;
                 struct v3d_vs_prog_data *vs;
                 struct v3d_fs_prog_data *fs;
+                struct v3d_compute_prog_data *compute;
         } prog_data;
 
         /**
@@ -169,8 +198,10 @@ struct v3d_compiled_shader {
 };
 
 struct v3d_program_stateobj {
-        struct v3d_uncompiled_shader *bind_vs, *bind_fs;
-        struct v3d_compiled_shader *cs, *vs, *fs;
+        struct v3d_uncompiled_shader *bind_vs, *bind_fs, *bind_compute;
+        struct v3d_compiled_shader *cs, *vs, *fs, *compute;
+
+        struct hash_table *cache[MESA_SHADER_STAGES];
 
         struct v3d_bo *spill_bo;
         int spill_size_per_thread;
@@ -190,10 +221,10 @@ struct v3d_vertexbuf_stateobj {
 };
 
 struct v3d_vertex_stateobj {
-        struct pipe_vertex_element pipe[VC5_MAX_ATTRIBUTES];
+        struct pipe_vertex_element pipe[V3D_MAX_VS_INPUTS / 4];
         unsigned num_elements;
 
-        uint8_t attrs[16 * VC5_MAX_ATTRIBUTES];
+        uint8_t attrs[16 * (V3D_MAX_VS_INPUTS / 4)];
         struct pipe_resource *defaults;
         uint32_t defaults_offset;
 };
@@ -386,7 +417,6 @@ struct v3d_context {
 
         struct primconvert_context *primconvert;
 
-        struct hash_table *fs_cache, *vs_cache;
         uint32_t next_uncompiled_program_id;
         uint64_t next_compiled_program_id;
 
@@ -418,6 +448,8 @@ struct v3d_context {
         struct v3d_depth_stencil_alpha_state *zsa;
 
         struct v3d_program_stateobj prog;
+        uint32_t compute_num_workgroups[3];
+        struct v3d_bo *compute_shared_memory;
 
         struct v3d_vertex_stateobj *vtx;
 
@@ -524,6 +556,7 @@ void v3d_query_init(struct pipe_context *pctx);
 
 void v3d_simulator_init(struct v3d_screen *screen);
 void v3d_simulator_destroy(struct v3d_screen *screen);
+uint32_t v3d_simulator_get_spill(uint32_t spill_size);
 int v3d_simulator_ioctl(int fd, unsigned long request, void *arg);
 void v3d_simulator_open_from_handle(int fd, int handle, uint32_t size);
 
@@ -555,6 +588,7 @@ void v3d_flush_jobs_writing_resource(struct v3d_context *v3d,
 void v3d_flush_jobs_reading_resource(struct v3d_context *v3d,
                                      struct pipe_resource *prsc);
 void v3d_update_compiled_shaders(struct v3d_context *v3d, uint8_t prim_mode);
+void v3d_update_compiled_cs(struct v3d_context *v3d);
 
 bool v3d_rt_format_supported(const struct v3d_device_info *devinfo,
                              enum pipe_format f);