v3d: Avoid duplicating limits defines between gallium and v3d core.
authorEric Anholt <eric@anholt.net>
Fri, 18 Jan 2019 23:36:15 +0000 (15:36 -0800)
committerEric Anholt <eric@anholt.net>
Sun, 27 Jan 2019 16:30:03 +0000 (08:30 -0800)
We don't want to pull the compiler into every include in the gallium
driver, so just make a new little header to store the limits.

src/broadcom/Makefile.sources
src/broadcom/common/v3d_limits.h [new file with mode: 0644]
src/broadcom/compiler/v3d_compiler.h
src/gallium/drivers/v3d/v3d_context.c
src/gallium/drivers/v3d/v3d_context.h
src/gallium/drivers/v3d/v3d_screen.c
src/gallium/drivers/v3d/v3d_screen.h
src/gallium/drivers/v3d/v3dx_draw.c
src/gallium/drivers/v3d/v3dx_state.c

index f8710c49752e33c86c787ceef14ba395eae339f8..6cec9b81cb11c02dae7649c57f522027800867c1 100644 (file)
@@ -21,6 +21,7 @@ BROADCOM_FILES = \
        common/v3d_debug.c \
        common/v3d_debug.h \
        common/v3d_device_info.h \
        common/v3d_debug.c \
        common/v3d_debug.h \
        common/v3d_device_info.h \
+       common/v3d_limits.h \
        common/v3d_macros.h \
        compiler/nir_to_vir.c \
        compiler/vir.c \
        common/v3d_macros.h \
        compiler/nir_to_vir.c \
        compiler/vir.c \
diff --git a/src/broadcom/common/v3d_limits.h b/src/broadcom/common/v3d_limits.h
new file mode 100644 (file)
index 0000000..367806d
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright © 2019 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 V3D_LIMITS_H
+#define V3D_LIMITS_H
+
+#define V3D_MAX_FS_INPUTS 64
+#define V3D_MAX_VS_INPUTS 64
+
+/* Not specifically a hardware limit, just coordination between compiler and
+ * driver.
+ */
+#define V3D_MAX_TEXTURE_SAMPLERS 32
+
+#define V3D_MAX_MIP_LEVELS 12
+
+#define V3D_MAX_SAMPLES 4
+
+#define V3D_MAX_DRAW_BUFFERS 4
+
+#endif /* V3D_LIMITS_H */
index a613146d9270e70fc65244fcb1b6b14c6b1a35a9..127b04136d18584a695406926361ca9b998168a9 100644 (file)
@@ -34,6 +34,7 @@
 #include "util/macros.h"
 #include "common/v3d_debug.h"
 #include "common/v3d_device_info.h"
 #include "util/macros.h"
 #include "common/v3d_debug.h"
 #include "common/v3d_device_info.h"
+#include "common/v3d_limits.h"
 #include "compiler/nir/nir.h"
 #include "util/list.h"
 #include "util/u_math.h"
 #include "compiler/nir/nir.h"
 #include "util/list.h"
 #include "util/u_math.h"
 #include "qpu/qpu_instr.h"
 #include "pipe/p_state.h"
 
 #include "qpu/qpu_instr.h"
 #include "pipe/p_state.h"
 
-#define V3D_MAX_TEXTURE_SAMPLERS 32
-#define V3D_MAX_SAMPLES 4
-#define V3D_MAX_FS_INPUTS 64
-#define V3D_MAX_VS_INPUTS 64
-
 struct nir_builder;
 
 struct v3d_fs_inputs {
 struct nir_builder;
 
 struct v3d_fs_inputs {
index 7e9bc3d22db01b5ef4f62774aa9838f2fe50bdb2..d07ad4035908e2c8c87b652d133aed68e9befbf9 100644 (file)
@@ -37,6 +37,7 @@
 #include "v3d_screen.h"
 #include "v3d_context.h"
 #include "v3d_resource.h"
 #include "v3d_screen.h"
 #include "v3d_context.h"
 #include "v3d_resource.h"
+#include "broadcom/compiler/v3d_compiler.h"
 
 void
 v3d_flush(struct pipe_context *pctx)
 
 void
 v3d_flush(struct pipe_context *pctx)
index 2ced7c8aa316e1e2b55f302a5fc677569c3ced03..3ec4940b6482baef3cf6c41c649187786770b9ea 100644 (file)
@@ -38,6 +38,7 @@
 #include "xf86drm.h"
 #include "v3d_drm.h"
 #include "v3d_screen.h"
 #include "xf86drm.h"
 #include "v3d_drm.h"
 #include "v3d_screen.h"
+#include "broadcom/common/v3d_limits.h"
 
 struct v3d_job;
 struct v3d_bo;
 
 struct v3d_job;
 struct v3d_bo;
@@ -190,10 +191,10 @@ struct v3d_vertexbuf_stateobj {
 };
 
 struct v3d_vertex_stateobj {
 };
 
 struct v3d_vertex_stateobj {
-        struct pipe_vertex_element pipe[V3D_MAX_ATTRIBUTES];
+        struct pipe_vertex_element pipe[V3D_MAX_VS_INPUTS / 4];
         unsigned num_elements;
 
         unsigned num_elements;
 
-        uint8_t attrs[16 * V3D_MAX_ATTRIBUTES];
+        uint8_t attrs[16 * (V3D_MAX_VS_INPUTS / 4)];
         struct pipe_resource *defaults;
         uint32_t defaults_offset;
 };
         struct pipe_resource *defaults;
         uint32_t defaults_offset;
 };
index 81392c9ff833916b61b518a57086a789276dc829..bed2c63a64d4d2a3d0af1cf58f9103ac5de26659 100644 (file)
@@ -262,7 +262,7 @@ v3d_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,
                 if (shader == PIPE_SHADER_FRAGMENT)
                         return V3D_MAX_FS_INPUTS / 4;
                 else
                 if (shader == PIPE_SHADER_FRAGMENT)
                         return V3D_MAX_FS_INPUTS / 4;
                 else
-                        return V3D_MAX_ATTRIBUTES;
+                        return V3D_MAX_VS_INPUTS / 4;
         case PIPE_SHADER_CAP_MAX_OUTPUTS:
                 if (shader == PIPE_SHADER_FRAGMENT)
                         return 4;
         case PIPE_SHADER_CAP_MAX_OUTPUTS:
                 if (shader == PIPE_SHADER_FRAGMENT)
                         return 4;
index 0975da2032fbd8d7ee2657966e45468e1d4e9878..94ae8b30f3a7d1c3b5092d888899ee852509713f 100644 (file)
 
 struct v3d_bo;
 
 
 struct v3d_bo;
 
-#define V3D_MAX_MIP_LEVELS 12
-#define V3D_MAX_TEXTURE_SAMPLERS 32
-#define V3D_MAX_SAMPLES 4
-#define V3D_MAX_DRAW_BUFFERS 4
-#define V3D_MAX_ATTRIBUTES 16
-
 /* These are tunable parameters in the HW design, but all the V3D
  * implementations agree.
  */
 /* These are tunable parameters in the HW design, but all the V3D
  * implementations agree.
  */
index 5ad4710876f9e1a3b6a4857be94fa48892d2a1da..2700208e3885f8c38317a8a0b7994373b2c72685 100644 (file)
@@ -317,7 +317,7 @@ v3d_emit_gl_shader_state(struct v3d_context *v3d,
                         attr.maximum_index = 0xffffff;
 #endif
                 }
                         attr.maximum_index = 0xffffff;
 #endif
                 }
-                STATIC_ASSERT(sizeof(vtx->attrs) >= V3D_MAX_ATTRIBUTES * size);
+                STATIC_ASSERT(sizeof(vtx->attrs) >= V3D_MAX_VS_INPUTS / 4 * size);
         }
 
         if (vtx->num_elements == 0) {
         }
 
         if (vtx->num_elements == 0) {
index b66569c25e721e8407635156f5365d1c43d24aa6..47b7ad03cc3c615792086a2cb0ead4a704616d86 100644 (file)
@@ -35,6 +35,7 @@
 #include "v3d_context.h"
 #include "v3d_tiling.h"
 #include "broadcom/common/v3d_macros.h"
 #include "v3d_context.h"
 #include "v3d_tiling.h"
 #include "broadcom/common/v3d_macros.h"
+#include "broadcom/compiler/v3d_compiler.h"
 #include "broadcom/cle/v3dx_pack.h"
 
 static void
 #include "broadcom/cle/v3dx_pack.h"
 
 static void
@@ -407,10 +408,10 @@ v3d_vertex_state_create(struct pipe_context *pctx, unsigned num_elements,
          */
         uint32_t *attrs;
         u_upload_alloc(v3d->state_uploader, 0,
          */
         uint32_t *attrs;
         u_upload_alloc(v3d->state_uploader, 0,
-                       V3D_MAX_ATTRIBUTES * 4 * sizeof(float), 16,
+                       V3D_MAX_VS_INPUTS * sizeof(float), 16,
                        &so->defaults_offset, &so->defaults, (void **)&attrs);
 
                        &so->defaults_offset, &so->defaults, (void **)&attrs);
 
-        for (int i = 0; i < V3D_MAX_ATTRIBUTES; i++) {
+        for (int i = 0; i < V3D_MAX_VS_INPUTS / 4; i++) {
                 attrs[i * 4 + 0] = 0;
                 attrs[i * 4 + 1] = 0;
                 attrs[i * 4 + 2] = 0;
                 attrs[i * 4 + 0] = 0;
                 attrs[i * 4 + 1] = 0;
                 attrs[i * 4 + 2] = 0;