Allow preshader support to be #ifdef'd out, to reduce binary size.
--- a/mojoshader.c Tue May 31 16:01:10 2011 -0400
+++ b/mojoshader.c Tue May 31 16:25:00 2011 -0400
@@ -7091,6 +7091,10 @@
if ((tokcount < 2) || (SWAP32(tokens[1]) != PRES_ID))
return; // not a preshader.
+#if !SUPPORT_PRESHADERS
+ fail(ctx, "Preshader found, but preshader support is disabled!");
+#else
+
assert(ctx->have_preshader == 0); // !!! FIXME: can you have more than one?
ctx->have_preshader = 1;
@@ -7396,6 +7400,7 @@
parse_preshader_cleanup:
free_symbols(ctx->free, ctx->malloc_data,
ctabdata.symbols, ctabdata.symbol_count);
+#endif
} // parse_preshader
--- a/mojoshader_effects.c Tue May 31 16:01:10 2011 -0400
+++ b/mojoshader_effects.c Tue May 31 16:25:00 2011 -0400
@@ -12,7 +12,9 @@
#include <math.h>
-void run_preshader(const MOJOSHADER_preshader *preshader, float *regs)
+#if SUPPORT_PRESHADERS
+void MOJOSHADER_runPreshader(const MOJOSHADER_preshader *preshader,
+ float *regs)
{
// this is fairly straightforward, as there aren't any branching
// opcodes in the preshader instruction set (at the moment, at least).
@@ -162,8 +164,8 @@
regs[operand->index + i] = (float) dst[i];
} // else
} // for
-} // run_preshader
-
+} // MOJOSHADER_runPreshader
+#endif
static MOJOSHADER_effect MOJOSHADER_out_of_mem_effect = {
1, &MOJOSHADER_out_of_mem_error, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
--- a/mojoshader_internal.h Tue May 31 16:01:10 2011 -0400
+++ b/mojoshader_internal.h Tue May 31 16:25:00 2011 -0400
@@ -60,7 +60,6 @@
#define SUPPORT_PROFILE_ARB1_NV 1
#endif
-
#if SUPPORT_PROFILE_ARB1_NV && !SUPPORT_PROFILE_ARB1
#error nv profiles require arb1 profile. Fix your build.
#endif
@@ -70,6 +69,20 @@
#endif
+// Other stuff you can disable...
+
+// This removes the preshader parsing and execution code. You can save some
+// bytes if you have normal shaders and not Effect files.
+#ifndef SUPPORT_PRESHADERS
+#define SUPPORT_PRESHADERS 1
+#endif
+
+#if SUPPORT_PRESHADERS
+void MOJOSHADER_runPreshader(const MOJOSHADER_preshader *, float *);
+#else
+#define MOJOSHADER_runPreshader(a, b)
+#endif
+
// Get basic wankery out of the way here...