[Mesa-dev] [PATCH 08/20] mesa: remove unused vertex attrib WEIGHT
Marek Olšák
maraeo at gmail.com
Tue Nov 21 18:01:50 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
We don't support ARB_vertex_blend.
Note that the attribute aliasing check for ARB_vertex_program had to be
rewritten.
vbo_context: 20344 -> 20008 bytes
gl_context: 74672 -> 74616 bytes
---
src/compiler/shader_enums.c | 1 -
src/compiler/shader_enums.h | 2 --
src/mesa/drivers/dri/r200/r200_maos_arrays.c | 4 +---
src/mesa/drivers/dri/r200/r200_vertprog.c | 5 -----
src/mesa/main/arrayobj.c | 3 ---
src/mesa/main/context.c | 1 -
src/mesa/program/prog_print.c | 1 -
src/mesa/program/program_lexer.l | 1 -
src/mesa/program/program_parse.y | 29 +++++++++++++++++++++-------
src/mesa/tnl/t_context.h | 3 +--
src/mesa/vbo/vbo_attrib.h | 1 -
11 files changed, 24 insertions(+), 27 deletions(-)
diff --git a/src/compiler/shader_enums.c b/src/compiler/shader_enums.c
index b2ca80b..2179c47 100644
--- a/src/compiler/shader_enums.c
+++ b/src/compiler/shader_enums.c
@@ -84,21 +84,20 @@ _mesa_shader_stage_to_abbrev(unsigned stage)
}
unreachable("Unknown shader stage.");
}
const char *
gl_vert_attrib_name(gl_vert_attrib attrib)
{
static const char *names[] = {
ENUM(VERT_ATTRIB_POS),
- ENUM(VERT_ATTRIB_WEIGHT),
ENUM(VERT_ATTRIB_NORMAL),
ENUM(VERT_ATTRIB_COLOR0),
ENUM(VERT_ATTRIB_COLOR1),
ENUM(VERT_ATTRIB_FOG),
ENUM(VERT_ATTRIB_COLOR_INDEX),
ENUM(VERT_ATTRIB_EDGEFLAG),
ENUM(VERT_ATTRIB_TEX0),
ENUM(VERT_ATTRIB_TEX1),
ENUM(VERT_ATTRIB_TEX2),
ENUM(VERT_ATTRIB_TEX3),
diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
index 17b236e..af4008c 100644
--- a/src/compiler/shader_enums.h
+++ b/src/compiler/shader_enums.h
@@ -68,21 +68,20 @@ const char *_mesa_shader_stage_to_abbrev(unsigned stage);
/**
* Indexes for vertex program attributes.
* GL_NV_vertex_program aliases generic attributes over the conventional
* attributes. In GL_ARB_vertex_program shader the aliasing is optional.
* In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the
* generic attributes are distinct/separate).
*/
typedef enum
{
VERT_ATTRIB_POS,
- VERT_ATTRIB_WEIGHT,
VERT_ATTRIB_NORMAL,
VERT_ATTRIB_COLOR0,
VERT_ATTRIB_COLOR1,
VERT_ATTRIB_FOG,
VERT_ATTRIB_COLOR_INDEX,
VERT_ATTRIB_EDGEFLAG,
VERT_ATTRIB_TEX0,
VERT_ATTRIB_TEX1,
VERT_ATTRIB_TEX2,
VERT_ATTRIB_TEX3,
@@ -134,21 +133,20 @@ const char *gl_vert_attrib_name(gl_vert_attrib attrib);
#define VERT_ATTRIB_GENERIC(i) (VERT_ATTRIB_GENERIC0 + (i))
#define VERT_ATTRIB_GENERIC_MAX MAX_VERTEX_GENERIC_ATTRIBS
/**
* Bitflags for vertex attributes.
* These are used in bitfields in many places.
*/
/*@{*/
#define VERT_BIT_POS BITFIELD64_BIT(VERT_ATTRIB_POS)
-#define VERT_BIT_WEIGHT BITFIELD64_BIT(VERT_ATTRIB_WEIGHT)
#define VERT_BIT_NORMAL BITFIELD64_BIT(VERT_ATTRIB_NORMAL)
#define VERT_BIT_COLOR0 BITFIELD64_BIT(VERT_ATTRIB_COLOR0)
#define VERT_BIT_COLOR1 BITFIELD64_BIT(VERT_ATTRIB_COLOR1)
#define VERT_BIT_FOG BITFIELD64_BIT(VERT_ATTRIB_FOG)
#define VERT_BIT_COLOR_INDEX BITFIELD64_BIT(VERT_ATTRIB_COLOR_INDEX)
#define VERT_BIT_EDGEFLAG BITFIELD64_BIT(VERT_ATTRIB_EDGEFLAG)
#define VERT_BIT_TEX0 BITFIELD64_BIT(VERT_ATTRIB_TEX0)
#define VERT_BIT_TEX1 BITFIELD64_BIT(VERT_ATTRIB_TEX1)
#define VERT_BIT_TEX2 BITFIELD64_BIT(VERT_ATTRIB_TEX2)
#define VERT_BIT_TEX3 BITFIELD64_BIT(VERT_ATTRIB_TEX3)
diff --git a/src/mesa/drivers/dri/r200/r200_maos_arrays.c b/src/mesa/drivers/dri/r200/r200_maos_arrays.c
index 60f851b..a3d45cf 100644
--- a/src/mesa/drivers/dri/r200/r200_maos_arrays.c
+++ b/src/mesa/drivers/dri/r200/r200_maos_arrays.c
@@ -95,23 +95,21 @@ void r200EmitArrays( struct gl_context *ctx, GLubyte *vimap_rev )
/* fallthrough */
case 3:
vfmt0 |= R200_VTX_Z0;
break;
case 2:
break;
default: assert(0);
}
break;
case 1:
- assert(attrib == VERT_ATTRIB_WEIGHT);
- emitsize = (VB->AttribPtr[attrib]->size);
- vfmt0 |= emitsize << R200_VTX_WEIGHT_COUNT_SHIFT;
+ unreachable("r200: vertex weight attrib unsupported");
break;
case 2:
assert(attrib == VERT_ATTRIB_NORMAL);
emitsize = 3;
vfmt0 |= R200_VTX_N0;
break;
case 3:
/* special handling to fix up fog. Will get us into trouble with vbos...*/
assert(attrib == VERT_ATTRIB_FOG);
if (!rmesa->radeon.tcl.aos[i].bo) {
diff --git a/src/mesa/drivers/dri/r200/r200_vertprog.c b/src/mesa/drivers/dri/r200/r200_vertprog.c
index bb85503..c3606b5 100644
--- a/src/mesa/drivers/dri/r200/r200_vertprog.c
+++ b/src/mesa/drivers/dri/r200/r200_vertprog.c
@@ -491,25 +491,20 @@ static GLboolean r200_translate_vertex_program(struct gl_context *ctx, struct r2
/* attr 4,5 and 13 are only used with generic attribs.
Haven't seen attr 14 used, maybe that's for the hw pointsize vec1 (which is
not possibe to use with vertex progs as it is lacking in vert prog specification) */
/* may look different when using idx buf / input_route instead of se_vtx_fmt? */
if (mesa_vp->info.inputs_read & VERT_BIT_POS) {
vp->inputs[VERT_ATTRIB_POS] = 0;
vp->inputmap_rev[0] = VERT_ATTRIB_POS;
free_inputs &= ~(1 << 0);
array_count++;
}
- if (mesa_vp->info.inputs_read & VERT_BIT_WEIGHT) {
- vp->inputs[VERT_ATTRIB_WEIGHT] = 12;
- vp->inputmap_rev[1] = VERT_ATTRIB_WEIGHT;
- array_count++;
- }
if (mesa_vp->info.inputs_read & VERT_BIT_NORMAL) {
vp->inputs[VERT_ATTRIB_NORMAL] = 1;
vp->inputmap_rev[2] = VERT_ATTRIB_NORMAL;
array_count++;
}
if (mesa_vp->info.inputs_read & VERT_BIT_COLOR0) {
vp->inputs[VERT_ATTRIB_COLOR0] = 2;
vp->inputmap_rev[4] = VERT_ATTRIB_COLOR0;
free_inputs &= ~(1 << 2);
array_count++;
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 88a5702..18d6d80 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -270,23 +270,20 @@ _mesa_initialize_vao(struct gl_context *ctx,
{
GLuint i;
vao->Name = name;
vao->RefCount = 1;
/* Init the individual arrays */
for (i = 0; i < ARRAY_SIZE(vao->VertexAttrib); i++) {
switch (i) {
- case VERT_ATTRIB_WEIGHT:
- init_array(ctx, vao, VERT_ATTRIB_WEIGHT, 1, GL_FLOAT);
- break;
case VERT_ATTRIB_NORMAL:
init_array(ctx, vao, VERT_ATTRIB_NORMAL, 3, GL_FLOAT);
break;
case VERT_ATTRIB_COLOR1:
init_array(ctx, vao, VERT_ATTRIB_COLOR1, 3, GL_FLOAT);
break;
case VERT_ATTRIB_FOG:
init_array(ctx, vao, VERT_ATTRIB_FOG, 1, GL_FLOAT);
break;
case VERT_ATTRIB_COLOR_INDEX:
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index fe91efe..05d2fdc 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -429,21 +429,20 @@ static void
_mesa_init_current(struct gl_context *ctx)
{
GLuint i;
/* Init all to (0,0,0,1) */
for (i = 0; i < ARRAY_SIZE(ctx->Current.Attrib); i++) {
ASSIGN_4V( ctx->Current.Attrib[i], 0.0, 0.0, 0.0, 1.0 );
}
/* redo special cases: */
- ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_WEIGHT], 1.0, 0.0, 0.0, 0.0 );
ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_NORMAL], 0.0, 0.0, 1.0, 1.0 );
ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR0], 1.0, 1.0, 1.0, 1.0 );
ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR1], 0.0, 0.0, 0.0, 1.0 );
ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX], 1.0, 0.0, 0.0, 1.0 );
ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG], 1.0, 0.0, 0.0, 1.0 );
}
/**
* Init vertex/fragment/geometry program limits.
diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c
index 4f85d14..9462510 100644
--- a/src/mesa/program/prog_print.c
+++ b/src/mesa/program/prog_print.c
@@ -82,21 +82,20 @@ _mesa_register_file_name(gl_register_file f)
* Return ARB_v/f_prog-style input attrib string.
*/
static const char *
arb_input_attrib_string(GLuint index, GLenum progType)
{
/*
* These strings should match the VERT_ATTRIB_x and VARYING_SLOT_x tokens.
*/
static const char *const vertAttribs[] = {
"vertex.position",
- "vertex.weight",
"vertex.normal",
"vertex.color.primary",
"vertex.color.secondary",
"vertex.fogcoord",
"vertex.(six)", /* VERT_ATTRIB_COLOR_INDEX */
"vertex.(seven)", /* VERT_ATTRIB_EDGEFLAG */
"vertex.texcoord[0]",
"vertex.texcoord[1]",
"vertex.texcoord[2]",
"vertex.texcoord[3]",
diff --git a/src/mesa/program/program_lexer.l b/src/mesa/program/program_lexer.l
index dee66cb..2e168b8 100644
--- a/src/mesa/program/program_lexer.l
+++ b/src/mesa/program/program_lexer.l
@@ -282,21 +282,20 @@ result { return RESULT; }
{dot}spot { return SPOT; }
{dot}texcoord { return TEXCOORD; }
{dot}texenv { return_token_or_DOT(require_ARB_fp, TEXENV); }
{dot}texgen { return_token_or_DOT(require_ARB_vp, TEXGEN); }
{dot}q { return_token_or_DOT(require_ARB_vp, TEXGEN_Q); }
{dot}s { return_token_or_DOT(require_ARB_vp, TEXGEN_S); }
{dot}t { return_token_or_DOT(require_ARB_vp, TEXGEN_T); }
{dot}texture { return TEXTURE; }
{dot}transpose { return TRANSPOSE; }
{dot}attrib { return_token_or_DOT(require_ARB_vp, VTXATTRIB); }
-{dot}weight { return_token_or_DOT(require_ARB_vp, WEIGHT); }
texture { return_token_or_IDENTIFIER(require_ARB_fp, TEXTURE_UNIT); }
1D { return_token_or_IDENTIFIER(require_ARB_fp, TEX_1D); }
2D { return_token_or_IDENTIFIER(require_ARB_fp, TEX_2D); }
3D { return_token_or_IDENTIFIER(require_ARB_fp, TEX_3D); }
CUBE { return_token_or_IDENTIFIER(require_ARB_fp, TEX_CUBE); }
RECT { return_token_or_IDENTIFIER(require_ARB_fp && require_rect, TEX_RECT); }
SHADOW1D { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW1D); }
SHADOW2D { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW2D); }
SHADOWRECT { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_rect, TEX_SHADOWRECT); }
diff --git a/src/mesa/program/program_parse.y b/src/mesa/program/program_parse.y
index f3adea6..1bc5f51 100644
--- a/src/mesa/program/program_parse.y
+++ b/src/mesa/program/program_parse.y
@@ -179,21 +179,20 @@ static struct asm_instruction *asm_instruction_copy_ctor(
%token NORMAL
%token OBJECT
%token PALETTE PARAMS PLANE POINT_TOK POINTSIZE POSITION PRIMARY PROGRAM PROJECTION
%token RANGE RESULT ROW
%token SCENECOLOR SECONDARY SHININESS SIZE_TOK SPECULAR SPOT STATE
%token TEXCOORD TEXENV TEXGEN TEXGEN_Q TEXGEN_R TEXGEN_S TEXGEN_T TEXTURE TRANSPOSE
%token TEXTURE_UNIT TEX_1D TEX_2D TEX_3D TEX_CUBE TEX_RECT
%token TEX_SHADOW1D TEX_SHADOW2D TEX_SHADOWRECT
%token TEX_ARRAY1D TEX_ARRAY2D TEX_ARRAYSHADOW1D TEX_ARRAYSHADOW2D
%token VERTEX VTXATTRIB
-%token WEIGHT
%token <string> IDENTIFIER USED_IDENTIFIER
%type <string> string
%token <swiz_mask> MASK4 MASK3 MASK2 MASK1 SWIZZLE
%token DOT_DOT
%token DOT
%type <inst> instruction ALU_instruction TexInstruction
%type <inst> ARL_instruction VECTORop_instruction
%type <inst> SCALARop_instruction BINSCop_instruction BINop_instruction
@@ -1000,24 +999,20 @@ attribBinding: VERTEX vtxAttribItem
| FRAGMENT fragAttribItem
{
$$ = $2;
}
;
vtxAttribItem: POSITION
{
$$ = VERT_ATTRIB_POS;
}
- | WEIGHT vtxOptWeightNum
- {
- $$ = VERT_ATTRIB_WEIGHT;
- }
| NORMAL
{
$$ = VERT_ATTRIB_NORMAL;
}
| COLOR optColorType
{
$$ = VERT_ATTRIB_COLOR0 + $2;
}
| FOGCOORD
{
@@ -1042,21 +1037,20 @@ vtxAttribNum: INTEGER
{
if ((unsigned) $1 >= state->limits->MaxAttribs) {
yyerror(& @1, state, "invalid vertex attribute reference");
YYERROR;
}
$$ = $1;
}
;
-vtxOptWeightNum: | '[' vtxWeightNum ']';
vtxWeightNum: INTEGER;
fragAttribItem: POSITION
{
$$ = VARYING_SLOT_POS;
}
| COLOR optColorType
{
$$ = VARYING_SLOT_COL0 + $2;
}
@@ -2212,22 +2206,43 @@ set_src_reg_swz(struct asm_src_register *r, gl_register_file file, GLint index,
* "used" included both reading the input or binding the input to a name using
* the \c ATTRIB command.
*
* \return
* \c TRUE if the combination of inputs used is valid, \c FALSE otherwise.
*/
int
validate_inputs(struct YYLTYPE *locp, struct asm_parser_state *state)
{
const GLbitfield64 inputs = state->prog->info.inputs_read | state->InputsBound;
+ GLbitfield ff_inputs = 0;
- if (((inputs & VERT_BIT_FF_ALL) & (inputs >> VERT_ATTRIB_GENERIC0)) != 0) {
+ /* Since Mesa internal attribute indices are different from
+ * how NV_vertex_program defines attribute aliasing, we have to construct
+ * a separate usage mask based on how the aliasing is defined.
+ *
+ * Note that attribute aliasing is optional if NV_vertex_program is
+ * unsupported.
+ */
+ if (inputs & VERT_BIT_POS)
+ ff_inputs |= 1 << 0;
+ if (inputs & VERT_BIT_NORMAL)
+ ff_inputs |= 1 << 2;
+ if (inputs & VERT_BIT_COLOR0)
+ ff_inputs |= 1 << 3;
+ if (inputs & VERT_BIT_COLOR1)
+ ff_inputs |= 1 << 4;
+ if (inputs & VERT_BIT_FOG)
+ ff_inputs |= 1 << 5;
+
+ ff_inputs |= ((inputs & VERT_BIT_TEX_ALL) >> VERT_ATTRIB_TEX0) << 8;
+
+ if ((ff_inputs & (inputs >> VERT_ATTRIB_GENERIC0)) != 0) {
yyerror(locp, state, "illegal use of generic attribute and name attribute");
return 0;
}
return 1;
}
struct asm_symbol *
declare_variable(struct asm_parser_state *state, char *name, enum asm_type t,
diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h
index 67a87f2..ced2857 100644
--- a/src/mesa/tnl/t_context.h
+++ b/src/mesa/tnl/t_context.h
@@ -70,21 +70,20 @@
* program instruction formats and register layouts.
*/
/* The bit space exhaustion is a fact now, done by _TNL_ATTRIB_ATTRIBUTE* for
* GLSL vertex shader which cannot be aliased with conventional vertex attribs.
* Compacting _TNL_ATTRIB_MAT_* attribs would not work, they would not give
* as many free bits (11 plus already 1 free bit) as _TNL_ATTRIB_ATTRIBUTE*
* attribs want (16).
*/
enum {
_TNL_ATTRIB_POS,
- _TNL_ATTRIB_WEIGHT,
_TNL_ATTRIB_NORMAL,
_TNL_ATTRIB_COLOR0,
_TNL_ATTRIB_COLOR1,
_TNL_ATTRIB_FOG,
_TNL_ATTRIB_COLOR_INDEX,
_TNL_ATTRIB_EDGEFLAG,
_TNL_ATTRIB_TEX0,
_TNL_ATTRIB_TEX1,
_TNL_ATTRIB_TEX2,
_TNL_ATTRIB_TEX3,
@@ -143,21 +142,21 @@ enum {
#define _TNL_ATTRIB_TEX(u) (_TNL_ATTRIB_TEX0 + (u))
#define _TNL_ATTRIB_GENERIC(n) (_TNL_ATTRIB_GENERIC0 + (n))
/* special index used for handing invalid glVertexAttribute() indices */
#define _TNL_ATTRIB_ERROR (_TNL_ATTRIB_GENERIC15 + 1)
/**
* Handy attribute ranges:
*/
-#define _TNL_FIRST_PROG _TNL_ATTRIB_WEIGHT
+#define _TNL_FIRST_PROG _TNL_ATTRIB_NORMAL
#define _TNL_LAST_PROG _TNL_ATTRIB_TEX7
#define _TNL_FIRST_TEX _TNL_ATTRIB_TEX0
#define _TNL_LAST_TEX _TNL_ATTRIB_TEX7
#define _TNL_FIRST_GENERIC _TNL_ATTRIB_GENERIC0
#define _TNL_LAST_GENERIC _TNL_ATTRIB_GENERIC15
#define _TNL_FIRST_MAT _TNL_ATTRIB_MAT_FRONT_AMBIENT /* GENERIC0 */
#define _TNL_LAST_MAT _TNL_ATTRIB_MAT_BACK_INDEXES /* GENERIC11 */
diff --git a/src/mesa/vbo/vbo_attrib.h b/src/mesa/vbo/vbo_attrib.h
index 560c826..f4a3a66 100644
--- a/src/mesa/vbo/vbo_attrib.h
+++ b/src/mesa/vbo/vbo_attrib.h
@@ -38,21 +38,20 @@
* in mtypes.h. However, the tnl module has additional attributes
* for materials, color indexes, edge flags, etc.
*/
/* Although it's nice to use these as bit indexes in a DWORD flag, we
* could manage without if necessary. Another limit currently is the
* number of bits allocated for these numbers in places like vertex
* program instruction formats and register layouts.
*/
enum {
VBO_ATTRIB_POS,
- VBO_ATTRIB_WEIGHT,
VBO_ATTRIB_NORMAL,
VBO_ATTRIB_COLOR0,
VBO_ATTRIB_COLOR1,
VBO_ATTRIB_FOG,
VBO_ATTRIB_INDEX,
VBO_ATTRIB_EDGEFLAG,
VBO_ATTRIB_TEX0,
VBO_ATTRIB_TEX1,
VBO_ATTRIB_TEX2,
VBO_ATTRIB_TEX3,
--
2.7.4
More information about the mesa-dev
mailing list