v3d: Avoid duplicating limits defines between gallium and v3d core.

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.
This commit is contained in:
Eric Anholt
2019-01-18 15:36:15 -08:00
parent fe6a21c867
commit 3e743d8cd8
9 changed files with 52 additions and 17 deletions

View File

@@ -21,6 +21,7 @@ BROADCOM_FILES = \
common/v3d_debug.c \ common/v3d_debug.c \
common/v3d_debug.h \ common/v3d_debug.h \
common/v3d_device_info.h \ common/v3d_device_info.h \
common/v3d_limits.h \
common/v3d_macros.h \ common/v3d_macros.h \
compiler/nir_to_vir.c \ compiler/nir_to_vir.c \
compiler/vir.c \ compiler/vir.c \

View File

@@ -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 */

View File

@@ -34,6 +34,7 @@
#include "util/macros.h" #include "util/macros.h"
#include "common/v3d_debug.h" #include "common/v3d_debug.h"
#include "common/v3d_device_info.h" #include "common/v3d_device_info.h"
#include "common/v3d_limits.h"
#include "compiler/nir/nir.h" #include "compiler/nir/nir.h"
#include "util/list.h" #include "util/list.h"
#include "util/u_math.h" #include "util/u_math.h"
@@ -41,11 +42,6 @@
#include "qpu/qpu_instr.h" #include "qpu/qpu_instr.h"
#include "pipe/p_state.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 nir_builder;
struct v3d_fs_inputs { struct v3d_fs_inputs {

View File

@@ -37,6 +37,7 @@
#include "v3d_screen.h" #include "v3d_screen.h"
#include "v3d_context.h" #include "v3d_context.h"
#include "v3d_resource.h" #include "v3d_resource.h"
#include "broadcom/compiler/v3d_compiler.h"
void void
v3d_flush(struct pipe_context *pctx) v3d_flush(struct pipe_context *pctx)

View File

@@ -38,6 +38,7 @@
#include "xf86drm.h" #include "xf86drm.h"
#include "v3d_drm.h" #include "v3d_drm.h"
#include "v3d_screen.h" #include "v3d_screen.h"
#include "broadcom/common/v3d_limits.h"
struct v3d_job; struct v3d_job;
struct v3d_bo; 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; struct pipe_resource *defaults;
uint32_t defaults_offset; uint32_t defaults_offset;
}; };

View File

@@ -262,7 +262,7 @@ v3d_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,
if (shader == PIPE_SHADER_FRAGMENT) if (shader == PIPE_SHADER_FRAGMENT)
return V3D_MAX_FS_INPUTS / 4; return V3D_MAX_FS_INPUTS / 4;
else else
return V3D_MAX_ATTRIBUTES; return V3D_MAX_VS_INPUTS / 4;
case PIPE_SHADER_CAP_MAX_OUTPUTS: case PIPE_SHADER_CAP_MAX_OUTPUTS:
if (shader == PIPE_SHADER_FRAGMENT) if (shader == PIPE_SHADER_FRAGMENT)
return 4; return 4;

View File

@@ -35,12 +35,6 @@
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 /* These are tunable parameters in the HW design, but all the V3D
* implementations agree. * implementations agree.
*/ */

View File

@@ -317,7 +317,7 @@ v3d_emit_gl_shader_state(struct v3d_context *v3d,
attr.maximum_index = 0xffffff; attr.maximum_index = 0xffffff;
#endif #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) {

View File

@@ -35,6 +35,7 @@
#include "v3d_context.h" #include "v3d_context.h"
#include "v3d_tiling.h" #include "v3d_tiling.h"
#include "broadcom/common/v3d_macros.h" #include "broadcom/common/v3d_macros.h"
#include "broadcom/compiler/v3d_compiler.h"
#include "broadcom/cle/v3dx_pack.h" #include "broadcom/cle/v3dx_pack.h"
static void static void
@@ -407,10 +408,10 @@ v3d_vertex_state_create(struct pipe_context *pctx, unsigned num_elements,
*/ */
uint32_t *attrs; uint32_t *attrs;
u_upload_alloc(v3d->state_uploader, 0, 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 + 0] = 0;
attrs[i * 4 + 1] = 0; attrs[i * 4 + 1] = 0;
attrs[i * 4 + 2] = 0; attrs[i * 4 + 2] = 0;