From 43fa79caba37eb41b17c0050c316637fba7dee43 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 31 May 2011 16:25:00 -0400 Subject: [PATCH] Allow preshader support to be #ifdef'd out, to reduce binary size. --- mojoshader.c | 5 +++++ mojoshader_effects.c | 8 +++++--- mojoshader_internal.h | 15 ++++++++++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/mojoshader.c b/mojoshader.c index 7c4c910b..5a20d849 100644 --- a/mojoshader.c +++ b/mojoshader.c @@ -7091,6 +7091,10 @@ static void parse_preshader(Context *ctx, uint32 tokcount) 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 @@ static void parse_preshader(Context *ctx, uint32 tokcount) parse_preshader_cleanup: free_symbols(ctx->free, ctx->malloc_data, ctabdata.symbols, ctabdata.symbol_count); +#endif } // parse_preshader diff --git a/mojoshader_effects.c b/mojoshader_effects.c index 5b1fd1c4..d79fe35f 100644 --- a/mojoshader_effects.c +++ b/mojoshader_effects.c @@ -12,7 +12,9 @@ #include -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 @@ void run_preshader(const MOJOSHADER_preshader *preshader, float *regs) 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 diff --git a/mojoshader_internal.h b/mojoshader_internal.h index bb84996e..ca3af0c6 100644 --- a/mojoshader_internal.h +++ b/mojoshader_internal.h @@ -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...