mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 07:11:41 +00:00
[qfcc] Support advanced progs again
The support for the new vector types broke compiling code using --advanced. Thus it's necessary to ensure vector constants are float-type and vec3 and vec4 are treated as vector and quaternion, which meant resurrecting the old vector expression code for v6p progs.
This commit is contained in:
parent
71af297a52
commit
2d3c2da64d
4 changed files with 73 additions and 2 deletions
|
@ -85,7 +85,7 @@ VISIBLE const v6p_opcode_t pr_v6p_opcodes[] = {
|
|||
ev_float, ev_float, ev_float,
|
||||
PROG_ID_VERSION,
|
||||
},
|
||||
[OP_MUL_V_v6p] = {"mul", "mul.v",
|
||||
[OP_MUL_V_v6p] = {"vdot", "mul.v",
|
||||
ev_vector, ev_vector, ev_float,
|
||||
PROG_ID_VERSION,
|
||||
},
|
||||
|
|
|
@ -212,6 +212,55 @@ check_types_compatible (expr_t *dst, expr_t *src)
|
|||
return type_mismatch (dst, src, '=');
|
||||
}
|
||||
|
||||
static void
|
||||
copy_qv_elements (expr_t *block, expr_t *dst, expr_t *src)
|
||||
{
|
||||
expr_t *dx, *sx;
|
||||
expr_t *dy, *sy;
|
||||
expr_t *dz, *sz;
|
||||
expr_t *dw, *sw;
|
||||
expr_t *ds, *ss;
|
||||
expr_t *dv, *sv;
|
||||
|
||||
if (is_vector (src->e.vector.type)) {
|
||||
// guaranteed to have three elements
|
||||
sx = src->e.vector.list;
|
||||
sy = sx->next;
|
||||
sz = sy->next;
|
||||
dx = field_expr (dst, new_name_expr ("x"));
|
||||
dy = field_expr (dst, new_name_expr ("y"));
|
||||
dz = field_expr (dst, new_name_expr ("z"));
|
||||
append_expr (block, assign_expr (dx, sx));
|
||||
append_expr (block, assign_expr (dy, sy));
|
||||
append_expr (block, assign_expr (dz, sz));
|
||||
} else {
|
||||
// guaranteed to have two or four elements
|
||||
if (src->e.vector.list->next->next) {
|
||||
// four vals: x, y, z, w
|
||||
sx = src->e.vector.list;
|
||||
sy = sx->next;
|
||||
sz = sy->next;
|
||||
sw = sz->next;
|
||||
dx = field_expr (dst, new_name_expr ("x"));
|
||||
dy = field_expr (dst, new_name_expr ("y"));
|
||||
dz = field_expr (dst, new_name_expr ("z"));
|
||||
dw = field_expr (dst, new_name_expr ("w"));
|
||||
append_expr (block, assign_expr (dx, sx));
|
||||
append_expr (block, assign_expr (dy, sy));
|
||||
append_expr (block, assign_expr (dz, sz));
|
||||
append_expr (block, assign_expr (dw, sw));
|
||||
} else {
|
||||
// v, s
|
||||
sv = src->e.vector.list;
|
||||
ss = sv->next;
|
||||
dv = field_expr (dst, new_name_expr ("v"));
|
||||
ds = field_expr (dst, new_name_expr ("s"));
|
||||
append_expr (block, assign_expr (dv, sv));
|
||||
append_expr (block, assign_expr (ds, ss));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
copy_elements (expr_t *block, expr_t *dst, expr_t *src, int base)
|
||||
{
|
||||
|
@ -234,7 +283,11 @@ assign_vector_expr (expr_t *dst, expr_t *src)
|
|||
if (src->type == ex_vector && dst->type != ex_vector) {
|
||||
expr_t *block = new_block_expr ();
|
||||
|
||||
copy_elements (block, dst, src, 0);
|
||||
if (options.code.progsversion <= PROG_VERSION) {
|
||||
copy_qv_elements (block, dst, src);
|
||||
} else {
|
||||
copy_elements (block, dst, src, 0);
|
||||
}
|
||||
block->e.block.result = dst;
|
||||
return block;
|
||||
}
|
||||
|
|
|
@ -587,6 +587,11 @@ parse_int_vector (const char *token, int width)
|
|||
}
|
||||
t1 = tolower (t1);
|
||||
t2 = tolower (t2);
|
||||
if (options.code.progsversion < PROG_VERSION) {
|
||||
if (!t1) {
|
||||
t1 = 'f';
|
||||
}
|
||||
}
|
||||
expr_t *expr = 0;
|
||||
switch (t1) {
|
||||
case 'u':
|
||||
|
@ -704,6 +709,11 @@ parse_float_vector (const char *token, int width)
|
|||
type = (t == 'f' || t == 'F') ? &type_vec2 : &type_dvec2;
|
||||
break;
|
||||
}
|
||||
if (options.code.progsversion < PROG_VERSION) {
|
||||
if (!t) {
|
||||
t = 'f';
|
||||
}
|
||||
}
|
||||
if (t == 'f' || t == 'F') {
|
||||
volatile union {
|
||||
pr_float_t f[4];
|
||||
|
|
|
@ -567,6 +567,14 @@ vector_type (const type_t *ele_type, int width)
|
|||
for (type_t **vtype = vec_types; *vtype; vtype++) {
|
||||
if ((*vtype)->type == ele_type->type
|
||||
&& (*vtype)->width == width) {
|
||||
if (options.code.progsversion <= PROG_VERSION) {
|
||||
if (*vtype == &type_vec3) {
|
||||
return &type_vector;
|
||||
}
|
||||
if (*vtype == &type_vec4) {
|
||||
return &type_quaternion;
|
||||
}
|
||||
}
|
||||
return *vtype;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue