uint8_t sourceRep; /* NV50_PROGRAM_IR */
const void *source;
void *relocData;
- void *interpData;
+ void *fixupData;
struct nv50_ir_prog_symbol *syms;
uint16_t numSyms;
} bin;
uint32_t dataPos);
extern void
-nv50_ir_change_interp(void *interpData, uint32_t *code,
- bool force_per_sample, bool flatshade);
+nv50_ir_apply_fixups(void *fixupData, uint32_t *code,
+ bool force_per_sample, bool flatshade);
/* obtain code that will be shared among programs */
extern void nv50_ir_get_target_library(uint32_t chipset,
}
static void
-interpApply(const InterpEntry *entry, uint32_t *code,
- bool force_persample_interp, bool flatshade)
+interpApply(const FixupEntry *entry, uint32_t *code, const FixupData& data)
{
int ipa = entry->ipa;
int reg = entry->reg;
int loc = entry->loc;
- if (flatshade &&
+ if (data.flatshade &&
(ipa & NV50_IR_INTERP_MODE_MASK) == NV50_IR_INTERP_SC) {
ipa = NV50_IR_INTERP_FLAT;
reg = 0xff;
- } else if (force_persample_interp &&
+ } else if (data.force_persample_interp &&
(ipa & NV50_IR_INTERP_SAMPLE_MASK) == NV50_IR_INTERP_DEFAULT &&
(ipa & NV50_IR_INTERP_MODE_MASK) != NV50_IR_INTERP_FLAT) {
ipa |= NV50_IR_INTERP_CENTROID;
}
static void
-interpApply(const InterpEntry *entry, uint32_t *code,
- bool force_persample_interp, bool flatshade)
+interpApply(const FixupEntry *entry, uint32_t *code, const FixupData& data)
{
int ipa = entry->ipa;
int reg = entry->reg;
int loc = entry->loc;
- if (flatshade &&
+ if (data.flatshade &&
(ipa & NV50_IR_INTERP_MODE_MASK) == NV50_IR_INTERP_SC) {
ipa = NV50_IR_INTERP_FLAT;
reg = 0xff;
- } else if (force_persample_interp &&
+ } else if (data.force_persample_interp &&
(ipa & NV50_IR_INTERP_SAMPLE_MASK) == NV50_IR_INTERP_DEFAULT &&
(ipa & NV50_IR_INTERP_MODE_MASK) != NV50_IR_INTERP_FLAT) {
ipa |= NV50_IR_INTERP_CENTROID;
}
static void
-interpApply(const InterpEntry *entry, uint32_t *code,
- bool force_persample_interp, bool flatshade)
+interpApply(const FixupEntry *entry, uint32_t *code, const FixupData& data)
{
int ipa = entry->ipa;
int encSize = entry->reg;
if ((ipa & NV50_IR_INTERP_SAMPLE_MASK) == NV50_IR_INTERP_DEFAULT &&
(ipa & NV50_IR_INTERP_MODE_MASK) != NV50_IR_INTERP_FLAT) {
- if (force_persample_interp) {
+ if (data.force_persample_interp) {
if (encSize == 8)
code[loc + 1] |= 1 << 16;
else
}
static void
-interpApply(const InterpEntry *entry, uint32_t *code,
- bool force_persample_interp, bool flatshade)
+interpApply(const FixupEntry *entry, uint32_t *code, const FixupData& data)
{
int ipa = entry->ipa;
int reg = entry->reg;
int loc = entry->loc;
- if (flatshade &&
+ if (data.flatshade &&
(ipa & NV50_IR_INTERP_MODE_MASK) == NV50_IR_INTERP_SC) {
ipa = NV50_IR_INTERP_FLAT;
reg = 0x3f;
- } else if (force_persample_interp &&
+ } else if (data.force_persample_interp &&
(ipa & NV50_IR_INTERP_SAMPLE_MASK) == NV50_IR_INTERP_DEFAULT &&
(ipa & NV50_IR_INTERP_MODE_MASK) != NV50_IR_INTERP_FLAT) {
ipa |= NV50_IR_INTERP_CENTROID;
delete targ;
}
-CodeEmitter::CodeEmitter(const Target *target) : targ(target), interpInfo(NULL)
+CodeEmitter::CodeEmitter(const Target *target) : targ(target), fixupInfo(NULL)
{
}
}
}
info->bin.relocData = emit->getRelocInfo();
- info->bin.interpData = emit->getInterpInfo();
+ info->bin.fixupData = emit->getFixupInfo();
emitSymbolTable(info);
}
bool
-CodeEmitter::addInterp(int ipa, int reg, InterpApply apply)
+CodeEmitter::addInterp(int ipa, int reg, FixupApply apply)
{
- unsigned int n = interpInfo ? interpInfo->count : 0;
+ unsigned int n = fixupInfo ? fixupInfo->count : 0;
if (!(n % RELOC_ALLOC_INCREMENT)) {
- size_t size = sizeof(InterpInfo) + n * sizeof(InterpEntry);
- interpInfo = reinterpret_cast<InterpInfo *>(
- REALLOC(interpInfo, n ? size : 0,
- size + RELOC_ALLOC_INCREMENT * sizeof(InterpEntry)));
- if (!interpInfo)
+ size_t size = sizeof(FixupInfo) + n * sizeof(FixupEntry);
+ fixupInfo = reinterpret_cast<FixupInfo *>(
+ REALLOC(fixupInfo, n ? size : 0,
+ size + RELOC_ALLOC_INCREMENT * sizeof(FixupEntry)));
+ if (!fixupInfo)
return false;
if (n == 0)
- memset(interpInfo, 0, sizeof(InterpInfo));
+ memset(fixupInfo, 0, sizeof(FixupInfo));
}
- ++interpInfo->count;
+ ++fixupInfo->count;
- interpInfo->entry[n] = InterpEntry(ipa, reg, codeSize >> 2);
- interpInfo->apply = apply;
+ fixupInfo->entry[n] = FixupEntry(apply, ipa, reg, codeSize >> 2);
return true;
}
}
void
-nv50_ir_change_interp(void *interpData, uint32_t *code,
- bool force_persample_interp, bool flatshade)
+nv50_ir_apply_fixups(void *fixupData, uint32_t *code,
+ bool force_persample_interp, bool flatshade)
{
- nv50_ir::InterpInfo *info = reinterpret_cast<nv50_ir::InterpInfo *>(
- interpData);
+ nv50_ir::FixupInfo *info = reinterpret_cast<nv50_ir::FixupInfo *>(
+ fixupData);
// force_persample_interp: all non-flat -> per-sample
// flatshade: all color -> flat
+ nv50_ir::FixupData data(force_persample_interp, flatshade);
for (unsigned i = 0; i < info->count; ++i)
- info->apply(&info->entry[i], code, force_persample_interp, flatshade);
+ info->entry[i].apply(&info->entry[i], code, data);
}
void
RelocEntry entry[0];
};
-struct InterpEntry
-{
- InterpEntry(int ipa, int reg, int loc) : ipa(ipa), reg(reg), loc(loc) {}
- uint32_t ipa:4; // SC mode used to identify colors
- uint32_t reg:8; // The reg used for perspective division
- uint32_t loc:20; // Let's hope we don't have more than 1M-sized shaders
+struct FixupData {
+ FixupData(bool force, bool flat) :
+ force_persample_interp(force), flatshade(flat) {}
+ bool force_persample_interp;
+ bool flatshade;
};
-typedef void (*InterpApply)(const InterpEntry*, uint32_t*, bool, bool);
+struct FixupEntry;
+typedef void (*FixupApply)(const FixupEntry*, uint32_t*, const FixupData&);
+
+struct FixupEntry
+{
+ FixupEntry(FixupApply apply, int ipa, int reg, int loc) :
+ apply(apply), ipa(ipa), reg(reg), loc(loc) {}
+
+ FixupApply apply;
+ union {
+ struct {
+ uint32_t ipa:4; // SC mode used to identify colors
+ uint32_t reg:8; // The reg used for perspective division
+ uint32_t loc:20; // Let's hope we don't have more than 1M-sized shaders
+ };
+ uint32_t val;
+ };
+};
-struct InterpInfo
+struct FixupInfo
{
uint32_t count;
- InterpApply apply;
- InterpEntry entry[0];
+ FixupEntry entry[0];
};
class CodeEmitter
inline void *getRelocInfo() const { return relocInfo; }
- bool addInterp(int ipa, int reg, InterpApply apply);
- inline void *getInterpInfo() const { return interpInfo; }
+ bool addInterp(int ipa, int reg, FixupApply apply);
+ inline void *getFixupInfo() const { return fixupInfo; }
virtual void prepareEmission(Program *);
virtual void prepareEmission(Function *);
uint32_t codeSizeLimit;
RelocInfo *relocInfo;
- InterpInfo *interpInfo;
+ FixupInfo *fixupInfo;
};
prog->code = info->bin.code;
prog->code_size = info->bin.codeSize;
prog->fixups = info->bin.relocData;
- prog->interps = info->bin.interpData;
+ prog->interps = info->bin.fixupData;
prog->max_gpr = MAX2(4, (info->bin.maxGPR >> 1) + 1);
prog->tls_space = info->bin.tlsSpace;
if (prog->fixups)
nv50_ir_relocate_code(prog->fixups, prog->code, prog->code_base, 0, 0);
if (prog->interps)
- nv50_ir_change_interp(prog->interps, prog->code,
- prog->fp.force_persample_interp,
- false /* flatshade */);
+ nv50_ir_apply_fixups(prog->interps, prog->code,
+ prog->fp.force_persample_interp,
+ false /* flatshade */);
nv50_sifc_linear_u8(&nv50->base, nv50->screen->code,
(prog_type << NV50_CODE_BO_SIZE_LOG2) + prog->code_base,
prog->immd_data = info->immd.buf;
prog->immd_size = info->immd.bufSize;
prog->relocs = info->bin.relocData;
- prog->interps = info->bin.interpData;
+ prog->fixups = info->bin.fixupData;
prog->num_gprs = MAX2(4, (info->bin.maxGPR + 1));
prog->num_barriers = info->numBarriers;
if (prog->relocs)
nv50_ir_relocate_code(prog->relocs, prog->code, code_pos, lib_pos, 0);
- if (prog->interps) {
- nv50_ir_change_interp(prog->interps, prog->code,
- prog->fp.force_persample_interp,
- prog->fp.flatshade);
+ if (prog->fixups) {
+ nv50_ir_apply_fixups(prog->fixups, prog->code,
+ prog->fp.force_persample_interp,
+ prog->fp.flatshade);
for (int i = 0; i < 2; i++) {
unsigned mask = prog->fp.color_interp[i] >> 4;
unsigned interp = prog->fp.color_interp[i] & 3;
FREE(prog->code); /* may be 0 for hardcoded shaders */
FREE(prog->immd_data);
FREE(prog->relocs);
- FREE(prog->interps);
+ FREE(prog->fixups);
if (prog->type == PIPE_SHADER_COMPUTE && prog->cp.syms)
FREE(prog->cp.syms);
if (prog->tfb) {
uint8_t num_barriers;
void *relocs;
- void *interps;
+ void *fixups;
struct nvc0_transform_feedback_state *tfb;