From 7323231002982e04e9e23092414ea81d0066a561 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 2 Mar 2013 17:34:52 +0100 Subject: [PATCH] (RGL) Cleanups --- console/rgl/include/RGL/Utils.h | 16 +++---------- console/rgl/src/rgl_cg.cpp | 40 +++++++++++++-------------------- 2 files changed, 19 insertions(+), 37 deletions(-) diff --git a/console/rgl/include/RGL/Utils.h b/console/rgl/include/RGL/Utils.h index 0ba86526c1..02300b6a7e 100644 --- a/console/rgl/include/RGL/Utils.h +++ b/console/rgl/include/RGL/Utils.h @@ -10,27 +10,17 @@ extern "C" { #endif #ifndef MSVC - // MAX that works with side effects. Just in case. -#define MAX(A,B) ({ \ - __typeof__(A) At=(A); \ - __typeof__(B) Bt=(B); \ - At>Bt?At:Bt; }) - -#define MIN(A,B) ({ \ - __typeof__(A) At=(A); \ - __typeof__(B) Bt=(B); \ - At(B)?(A):(B)) -#define MIN(A,B) ((A)<(B)?(A):(B)) #define RGL_LIKELY(COND) (COND) #define RGL_UNLIKELY(COND) (COND) #endif +#define MAX(A,B) ((A)>(B)?(A):(B)) +#define MIN(A,B) ((A)<(B)?(A):(B)) + #define _RGL_FLOAT_AS_UINT(x) ({union {float f; unsigned int i;} u; u.f=(x); u.i;}) static inline float rglClampf( const float value ) diff --git a/console/rgl/src/rgl_cg.cpp b/console/rgl/src/rgl_cg.cpp index 93d8c3d231..73aa995927 100644 --- a/console/rgl/src/rgl_cg.cpp +++ b/console/rgl/src/rgl_cg.cpp @@ -7049,9 +7049,7 @@ static unsigned int stringTableAddUnique( std::vector &stringTable, const return ret; } -template static size_t array_size(std::vector &array); template static void array_push(char* ¶meterOffset, std::vector &array); -inline static uint32_t swap16(const uint32_t v); static unsigned short getFlags(CGenum var, CGenum dir, int no, bool is_referenced, bool is_shared, int paramIndex); ////////////////////////////////////////////////////////////////////////////// @@ -7091,6 +7089,11 @@ int convertNvToElfFromFile(const char *sourceFile, int endianness, int constTabl return -1; } +static inline uint32_t swap16(const uint32_t v) +{ + return (v>>16) | (v<<16); +} + int convertNvToElfFromMemory(const void *sourceData, size_t size, int endianness, int constTableOffset, void **binaryShader, int *binarySize, std::vector &stringTable, std::vector &defaultValues) { @@ -7201,7 +7204,8 @@ int convertNvToElfFromMemory(const void *sourceData, size_t size, int endianness { int size = (int)nvbr->ucode_size()/sizeof(uint32_t); buffer = new uint32_t[size]; - for (int i=0;iucode_size()/sizeof(uint32_t); buffer = new uint32_t[size]; - for (int i=0;i static size_t array_size(std::vector &array) -{ - return (unsigned int)array.size()*sizeof(array[0]); -} - template static void array_push(char* ¶meterOffset, std::vector &array) { size_t dataSize = array.size()*sizeof(array[0]); @@ -8221,10 +8217,6 @@ template static void array_push(char* ¶meterOffset, std::vector< parameterOffset += dataSize; } -uint32_t inline static swap16(const uint32_t v) -{ - return (v>>16) | (v<<16); -} unsigned short getFlags(CGenum var, CGenum dir, int no, bool is_referenced, bool is_shared, int paramIndex) {