From 0d03822d0a21dccc218f60e38b609b1ea0b8e61d Mon Sep 17 00:00:00 2001 From: fincs Date: Sat, 18 Mar 2017 00:46:37 +0100 Subject: [PATCH] Support (dummy) o7-o15 output registers in vertex shaders --- source/picasso.h | 7 ++++++- source/picasso_assembler.cpp | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/source/picasso.h b/source/picasso.h index 9ef344a..a97005a 100644 --- a/source/picasso.h +++ b/source/picasso.h @@ -229,12 +229,17 @@ struct DVLEData bool usesGshSpace() { return isGeoShader && !isCompatGeoShader; } int findFreeOutput() { - for (int i = 0; i < 7; i ++) + for (int i = 0; i < maxOutputReg(); i ++) if (!(outputMask & BIT(i))) return i; return -1; } + int maxOutputReg() const + { + return isGeoShader ? 0x07 : 0x10; + } + DVLEData(const char* filename) : filename(filename), entrypoint("main"), nodvle(false), isGeoShader(false), isCompatGeoShader(false), isMerge(false), diff --git a/source/picasso_assembler.cpp b/source/picasso_assembler.cpp index 71e4ab7..3296a55 100644 --- a/source/picasso_assembler.cpp +++ b/source/picasso_assembler.cpp @@ -737,7 +737,7 @@ static int parseReg(char* pos, int& outReg, int& outSw, int* idxType = NULL) switch (*pos) { case 'o': // Output registers - if (outReg < 0x00 || outReg >= 0x07) + if (outReg < 0x00 || outReg >= GetDvleData()->maxOutputReg()) return throwError("invalid output register: %s\n", pos); break; case 'v': // Input attributes @@ -1797,7 +1797,7 @@ DEF_DIRECTIVE(out) if (outDestRegName) { ARG_TO_REG(outDestReg, outDestRegName); - if (outDestReg < 0x00 || outDestReg >= 0x07) + if (outDestReg < 0x00 || outDestReg >= dvle->maxOutputReg()) return throwError("invalid output register: %s\n", outDestRegName); oid = outDestReg; sw = outDestRegSw; @@ -1831,6 +1831,9 @@ DEF_DIRECTIVE(out) if (outName && g_aliases.find(outName) != g_aliases.end()) return duplicateIdentifier(outName); + if (oid >= 7 && type != OUTTYPE_DUMMY) + return throwError("this register (o%d) can only be a dummy output\n", oid); + #ifdef DEBUG printf("output %s <- o%d (%d:%X)\n", outName, oid, type, mask); #endif