vc4: Move qir_uniform() and the constant-value versions to vc4_qir.c/h.
I may want them in optimization passes, and they're not really particular to the program translation stage.
This commit is contained in:
parent
14dc281c13
commit
877b48a531
|
@ -109,51 +109,6 @@ resize_qreg_array(struct vc4_compile *c,
|
||||||
(*regs)[i] = c->undef;
|
(*regs)[i] = c->undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct qreg
|
|
||||||
qir_uniform(struct vc4_compile *c,
|
|
||||||
enum quniform_contents contents,
|
|
||||||
uint32_t data)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < c->num_uniforms; i++) {
|
|
||||||
if (c->uniform_contents[i] == contents &&
|
|
||||||
c->uniform_data[i] == data) {
|
|
||||||
return (struct qreg) { QFILE_UNIF, i };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t uniform = c->num_uniforms++;
|
|
||||||
struct qreg u = { QFILE_UNIF, uniform };
|
|
||||||
|
|
||||||
if (uniform >= c->uniform_array_size) {
|
|
||||||
c->uniform_array_size = MAX2(MAX2(16, uniform + 1),
|
|
||||||
c->uniform_array_size * 2);
|
|
||||||
|
|
||||||
c->uniform_data = reralloc(c, c->uniform_data,
|
|
||||||
uint32_t,
|
|
||||||
c->uniform_array_size);
|
|
||||||
c->uniform_contents = reralloc(c, c->uniform_contents,
|
|
||||||
enum quniform_contents,
|
|
||||||
c->uniform_array_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
c->uniform_contents[uniform] = contents;
|
|
||||||
c->uniform_data[uniform] = data;
|
|
||||||
|
|
||||||
return u;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct qreg
|
|
||||||
qir_uniform_ui(struct vc4_compile *c, uint32_t ui)
|
|
||||||
{
|
|
||||||
return qir_uniform(c, QUNIFORM_CONSTANT, ui);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct qreg
|
|
||||||
qir_uniform_f(struct vc4_compile *c, float f)
|
|
||||||
{
|
|
||||||
return qir_uniform(c, QUNIFORM_CONSTANT, fui(f));
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct qreg
|
static struct qreg
|
||||||
indirect_uniform_load(struct vc4_compile *c,
|
indirect_uniform_load(struct vc4_compile *c,
|
||||||
struct tgsi_full_src_register *src, int swiz)
|
struct tgsi_full_src_register *src, int swiz)
|
||||||
|
|
|
@ -423,6 +423,39 @@ qir_get_stage_name(enum qstage stage)
|
||||||
return names[stage];
|
return names[stage];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct qreg
|
||||||
|
qir_uniform(struct vc4_compile *c,
|
||||||
|
enum quniform_contents contents,
|
||||||
|
uint32_t data)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < c->num_uniforms; i++) {
|
||||||
|
if (c->uniform_contents[i] == contents &&
|
||||||
|
c->uniform_data[i] == data) {
|
||||||
|
return (struct qreg) { QFILE_UNIF, i };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t uniform = c->num_uniforms++;
|
||||||
|
struct qreg u = { QFILE_UNIF, uniform };
|
||||||
|
|
||||||
|
if (uniform >= c->uniform_array_size) {
|
||||||
|
c->uniform_array_size = MAX2(MAX2(16, uniform + 1),
|
||||||
|
c->uniform_array_size * 2);
|
||||||
|
|
||||||
|
c->uniform_data = reralloc(c, c->uniform_data,
|
||||||
|
uint32_t,
|
||||||
|
c->uniform_array_size);
|
||||||
|
c->uniform_contents = reralloc(c, c->uniform_contents,
|
||||||
|
enum quniform_contents,
|
||||||
|
c->uniform_array_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
c->uniform_contents[uniform] = contents;
|
||||||
|
c->uniform_data[uniform] = data;
|
||||||
|
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
qir_SF(struct vc4_compile *c, struct qreg src)
|
qir_SF(struct vc4_compile *c, struct qreg src)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include "util/macros.h"
|
#include "util/macros.h"
|
||||||
#include "util/simple_list.h"
|
#include "util/simple_list.h"
|
||||||
|
#include "util/u_math.h"
|
||||||
#include "tgsi/tgsi_parse.h"
|
#include "tgsi/tgsi_parse.h"
|
||||||
|
|
||||||
enum qfile {
|
enum qfile {
|
||||||
|
@ -368,6 +369,9 @@ struct qinst *qir_inst4(enum qop op, struct qreg dst,
|
||||||
struct qreg c,
|
struct qreg c,
|
||||||
struct qreg d);
|
struct qreg d);
|
||||||
void qir_remove_instruction(struct qinst *qinst);
|
void qir_remove_instruction(struct qinst *qinst);
|
||||||
|
struct qreg qir_uniform(struct vc4_compile *c,
|
||||||
|
enum quniform_contents contents,
|
||||||
|
uint32_t data);
|
||||||
void qir_reorder_uniforms(struct vc4_compile *c);
|
void qir_reorder_uniforms(struct vc4_compile *c);
|
||||||
void qir_emit(struct vc4_compile *c, struct qinst *inst);
|
void qir_emit(struct vc4_compile *c, struct qinst *inst);
|
||||||
struct qreg qir_get_temp(struct vc4_compile *c);
|
struct qreg qir_get_temp(struct vc4_compile *c);
|
||||||
|
@ -400,6 +404,18 @@ void qpu_schedule_instructions(struct vc4_compile *c);
|
||||||
|
|
||||||
void qir_SF(struct vc4_compile *c, struct qreg src);
|
void qir_SF(struct vc4_compile *c, struct qreg src);
|
||||||
|
|
||||||
|
static inline struct qreg
|
||||||
|
qir_uniform_ui(struct vc4_compile *c, uint32_t ui)
|
||||||
|
{
|
||||||
|
return qir_uniform(c, QUNIFORM_CONSTANT, ui);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline struct qreg
|
||||||
|
qir_uniform_f(struct vc4_compile *c, float f)
|
||||||
|
{
|
||||||
|
return qir_uniform(c, QUNIFORM_CONSTANT, fui(f));
|
||||||
|
}
|
||||||
|
|
||||||
#define QIR_ALU0(name) \
|
#define QIR_ALU0(name) \
|
||||||
static inline struct qreg \
|
static inline struct qreg \
|
||||||
qir_##name(struct vc4_compile *c) \
|
qir_##name(struct vc4_compile *c) \
|
||||||
|
|
Loading…
Reference in New Issue