mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-22 21:30:31 +01:00
Implement constant sharing so that 4 float constants can share a single
float[4] register slot.
This commit is contained in:
parent
ce6640001d
commit
16183e6430
2 changed files with 19 additions and 12 deletions
|
|
@ -546,8 +546,12 @@ new_label(slang_atom labName)
|
|||
static slang_ir_node *
|
||||
new_float_literal(float x, float y, float z, float w)
|
||||
{
|
||||
GLuint size = 4; /* XXX fix */
|
||||
GLuint size;
|
||||
slang_ir_node *n = new_node(IR_FLOAT, NULL, NULL);
|
||||
if (x == y && x == z && x == w)
|
||||
size = 1;
|
||||
else
|
||||
size = 4;
|
||||
n->Value[0] = x;
|
||||
n->Value[1] = y;
|
||||
n->Value[2] = z;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
#include "prog_parameter.h"
|
||||
#include "prog_print.h"
|
||||
#include "slang_emit.h"
|
||||
#include "slang_error.h"
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -125,22 +126,20 @@ slang_ir_name(slang_ir_opcode opcode)
|
|||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* Swizzle a swizzle.
|
||||
* Swizzle a swizzle. That is, return swz2(swz1)
|
||||
*/
|
||||
static GLuint
|
||||
swizzle_compose(GLuint swz1, GLuint swz2)
|
||||
swizzle_swizzle(GLuint swz1, GLuint swz2)
|
||||
{
|
||||
GLuint i, swz, s[4];
|
||||
for (i = 0; i < 4; i++) {
|
||||
GLuint c = GET_SWZ(swz1, i);
|
||||
s[i] = GET_SWZ(swz2, c);
|
||||
GLuint c = GET_SWZ(swz2, i);
|
||||
s[i] = GET_SWZ(swz1, c);
|
||||
}
|
||||
swz = MAKE_SWIZZLE4(s[0], s[1], s[2], s[3]);
|
||||
return swz;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
slang_ir_storage *
|
||||
|
|
@ -381,7 +380,7 @@ storage_to_src_reg(struct prog_src_register *src, const slang_ir_storage *st,
|
|||
assert(st->Size >= 1);
|
||||
assert(st->Size <= 4);
|
||||
/* XXX swizzling logic here may need some work */
|
||||
/*src->Swizzle = swizzle_compose(swizzle, defaultSwizzle[st->Size - 1]);*/
|
||||
/*src->Swizzle = swizzle_swizzlee(swizzle, defaultSwizzle[st->Size - 1]);*/
|
||||
if (st->Swizzle != SWIZZLE_NOOP)
|
||||
src->Swizzle = st->Swizzle;
|
||||
else
|
||||
|
|
@ -767,7 +766,8 @@ emit(slang_var_table *vt, slang_ir_node *n, struct gl_program *prog)
|
|||
n->Store->Index = n->Children[0]->Store->Index;
|
||||
n->Store->Size = n->Children[0]->Store->Size;
|
||||
assert(n->Store->Index >= 0);
|
||||
/* XXX compose swizzles here!!! */
|
||||
n->Store->Swizzle = swizzle_swizzle(n->Children[0]->Store->Swizzle,
|
||||
n->Store->Swizzle);
|
||||
return NULL;
|
||||
|
||||
/* Simple binary operators */
|
||||
|
|
@ -806,10 +806,13 @@ emit(slang_var_table *vt, slang_ir_node *n, struct gl_program *prog)
|
|||
case IR_NEG:
|
||||
return emit_negation(vt, n, prog);
|
||||
case IR_FLOAT:
|
||||
/* find storage location for this float */
|
||||
/* find storage location for this float constant */
|
||||
n->Store->Index = _mesa_add_unnamed_constant(prog->Parameters, n->Value,
|
||||
4, &n->Store->Swizzle);
|
||||
assert(n->Store->Index >= 0);
|
||||
n->Store->Size/*4*/,
|
||||
&n->Store->Swizzle);
|
||||
if (n->Store->Index < 0) {
|
||||
RETURN_ERROR("Ran out of space for constants.", 0);
|
||||
}
|
||||
return NULL;
|
||||
|
||||
case IR_MOVE:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue