Compile out things irrelevant for target build, like ShaderGenerator when !HAVE_CG

This commit is contained in:
rdb 2015-04-06 13:24:45 +02:00
parent 3d2d1d9c23
commit adb02a8f45
10 changed files with 55 additions and 21 deletions

View File

@ -2001,9 +2001,11 @@ setup_scene(GraphicsStateGuardian *gsg, DisplayRegionPipelineReader *dr) {
// to use. We have to do this here because the ShaderGenerator // to use. We have to do this here because the ShaderGenerator
// needs a host window pointer. Hopefully we'll be able to // needs a host window pointer. Hopefully we'll be able to
// eliminate that requirement in the future. // eliminate that requirement in the future.
#ifdef HAVE_CG
if (gsg->get_shader_generator() == NULL) { if (gsg->get_shader_generator() == NULL) {
gsg->set_shader_generator(new ShaderGenerator(gsg, window)); gsg->set_shader_generator(new ShaderGenerator(gsg, window));
} }
#endif
return scene_setup; return scene_setup;
} }

View File

@ -365,6 +365,7 @@ munge_state_impl(const RenderState *state) {
munged_state = munged_state->remove_attrib(ColorScaleAttrib::get_class_slot()); munged_state = munged_state->remove_attrib(ColorScaleAttrib::get_class_slot());
} }
#ifdef HAVE_CG
if (_auto_shader) { if (_auto_shader) {
CPT(RenderState) shader_state = munged_state->get_auto_shader_state(); CPT(RenderState) shader_state = munged_state->get_auto_shader_state();
ShaderGenerator *shader_generator = get_gsg()->get_shader_generator(); ShaderGenerator *shader_generator = get_gsg()->get_shader_generator();
@ -379,6 +380,7 @@ munge_state_impl(const RenderState *state) {
} }
munged_state = munged_state->set_attrib(shader_state->_generated_shader); munged_state = munged_state->set_attrib(shader_state->_generated_shader);
} }
#endif
return munged_state; return munged_state;
} }

View File

@ -17,6 +17,7 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#include "shaderGenerator.h" #include "shaderGenerator.h"
#include "renderState.h" #include "renderState.h"
#include "shaderAttrib.h" #include "shaderAttrib.h"
#include "auxBitplaneAttrib.h" #include "auxBitplaneAttrib.h"
@ -44,6 +45,8 @@
TypeHandle ShaderGenerator::_type_handle; TypeHandle ShaderGenerator::_type_handle;
#ifdef HAVE_CG
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: ShaderGenerator::Constructor // Function: ShaderGenerator::Constructor
// Access: Published // Access: Published
@ -1636,3 +1639,5 @@ texture_type_as_string(Texture::TextureType ttype) {
return "2D"; return "2D";
} }
} }
#endif // HAVE_CG

View File

@ -17,6 +17,10 @@
#define SHADERGENERATOR_H #define SHADERGENERATOR_H
#include "pandabase.h" #include "pandabase.h"
#include "typedReferenceCount.h"
#ifdef HAVE_CG
#include "graphicsStateGuardianBase.h" #include "graphicsStateGuardianBase.h"
#include "graphicsOutputBase.h" #include "graphicsOutputBase.h"
#include "nodePath.h" #include "nodePath.h"
@ -169,10 +173,34 @@ public:
} }
virtual TypeHandle force_init_type() {init_type(); return get_class_type();} virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private: private:
static TypeHandle _type_handle;
};
#else
// If we don't have Cg, let's replace this with a stub.
class EXPCL_PANDA_PGRAPHNODES ShaderGenerator : public TypedReferenceCount {
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
TypedObject::init_type();
register_type(_type_handle, "ShaderGenerator",
TypedObject::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle; static TypeHandle _type_handle;
}; };
#include "shaderGenerator.I" #include "shaderGenerator.I"
#endif // HAVE_CG
#endif // SHADERGENERATOR_H #endif // SHADERGENERATOR_H

View File

@ -162,12 +162,4 @@ has_sse2_sRGB_encode() {
return has_support; return has_support;
} }
#else
// Other architectures don't support SSE2 at all.
bool
has_sse2_sRGB_encode() {
return false;
}
#endif // __SSE2__ #endif // __SSE2__

View File

@ -45,6 +45,7 @@ EXPCL_PANDA_PNMIMAGE INLINE void encode_sRGB_uchar(const LColorf &from,
// Use these functions if you know that SSE2 support is available. // Use these functions if you know that SSE2 support is available.
// Otherwise, they will crash! // Otherwise, they will crash!
#if defined(__SSE2__) || defined(__i386__) || defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64)
EXPCL_PANDA_PNMIMAGE unsigned char encode_sRGB_uchar_sse2(float val); EXPCL_PANDA_PNMIMAGE unsigned char encode_sRGB_uchar_sse2(float val);
EXPCL_PANDA_PNMIMAGE void encode_sRGB_uchar_sse2(const LColorf &from, EXPCL_PANDA_PNMIMAGE void encode_sRGB_uchar_sse2(const LColorf &from,
xel &into); xel &into);
@ -53,6 +54,11 @@ EXPCL_PANDA_PNMIMAGE void encode_sRGB_uchar_sse2(const LColorf &from,
// Use the following to find out if you can call either of the above. // Use the following to find out if you can call either of the above.
EXPCL_PANDA_PNMIMAGE bool has_sse2_sRGB_encode(); EXPCL_PANDA_PNMIMAGE bool has_sse2_sRGB_encode();
#else
// The target architecture can't support the SSE2 extension at all.
#define encode_sRGB_uchar_sse2 encode_sRGB_uchar
#define has_sse2_sRGB_encode() (false)
#endif
#include "convert_srgb.I" #include "convert_srgb.I"

View File

@ -127,10 +127,11 @@ encode_sRGB_uchar_sse2(const LColorf &color, xel &into, xelval &into_alpha) {
into_alpha = _mm_extract_epi16(vals, 6); into_alpha = _mm_extract_epi16(vals, 6);
} }
#else #elif defined(__i386__) || defined(_M_IX86)
// Somehow we're still compiling this without SSE2 support. We'll // Somehow we're still compiling this without SSE2 support, even though the
// still have to define these functions, but emit a warning that the // target architecture could (in theory) support SSE2. We still have to
// build system isn't configured properly. // define these functions, but emit a warning that the build system isn't
// configured properly.
#warning convert_srgb_sse2.cxx is being compiled without SSE2 support! #warning convert_srgb_sse2.cxx is being compiled without SSE2 support!
unsigned char unsigned char

View File

@ -862,10 +862,8 @@ generate_hash(ChecksumHashGenerator &hashgen) const {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
template<class WType, int nbits> template<class WType, int nbits>
void BitMask<WType, nbits>:: void BitMask<WType, nbits>::
init_type() { init_type(const string &name) {
ostringstream str; register_type(_type_handle, name);
str << "BitMask" << num_bits;
register_type(_type_handle, str.str());
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -144,7 +144,7 @@ public:
static TypeHandle get_class_type() { static TypeHandle get_class_type() {
return _type_handle; return _type_handle;
} }
static void init_type(); static void init_type(const string &name);
private: private:
static TypeHandle _type_handle; static TypeHandle _type_handle;

View File

@ -181,9 +181,9 @@ init_libputil() {
BamReaderAuxData::init_type(); BamReaderAuxData::init_type();
BamReaderParam::init_type(); BamReaderParam::init_type();
BitArray::init_type(); BitArray::init_type();
BitMask16::init_type(); BitMask16::init_type("BitMask16");
BitMask32::init_type(); BitMask32::init_type("BitMask32");
BitMask64::init_type(); BitMask64::init_type("BitMask64");
ButtonHandle::init_type(); ButtonHandle::init_type();
ButtonMap::init_type(); ButtonMap::init_type();
CPointerCallbackObject::init_type(); CPointerCallbackObject::init_type();