ShaderGenCommon: Introduce a common shader generator interface to make stuff less confusing.

This commit is contained in:
NeoBrainX 2013-03-26 23:03:10 +01:00
parent 3253603ae7
commit 0e31943216
1 changed files with 14 additions and 15 deletions

View File

@ -26,7 +26,18 @@
#include <vector>
template<class uid_data>
class ShaderUid
class ShaderGeneratorInterface
{
public:
void Write(const char* fmt, ...) {}
const char* GetBuffer() { return NULL; }
void SetBuffer(char* buffer) { }
inline void SetConstantsUsed(unsigned int first_index, unsigned int last_index) {}
uid_data& GetUidData() { return *(uid_data*)NULL; }
};
template<class uid_data>
class ShaderUid : public ShaderGeneratorInterface<uid_data>
{
public:
ShaderUid()
@ -35,11 +46,6 @@ public:
memset(values, 0, sizeof(values));
}
void Write(const char* fmt, ...) {}
const char* GetBuffer() { return NULL; }
void SetBuffer(char* buffer) { }
inline void SetConstantsUsed(unsigned int first_index, unsigned int last_index) {}
bool operator == (const ShaderUid& obj) const
{
return memcmp(this->values, obj.values, sizeof(values)) == 0;
@ -70,7 +76,7 @@ private:
// Needs to be a template for hacks...
template<class uid_data>
class ShaderCode
class ShaderCode : public ShaderGeneratorInterface<uid_data>
{
public:
ShaderCode() : buf(NULL), write_ptr(NULL)
@ -88,8 +94,6 @@ public:
const char* GetBuffer() { return buf; }
void SetBuffer(char* buffer) { buf = buffer; write_ptr = buffer; }
uid_data& GetUidData() { return *(uid_data*)NULL; }
inline void SetConstantsUsed(unsigned int first_index, unsigned int last_index) {}
private:
const char* buf;
@ -97,16 +101,11 @@ private:
};
template<class uid_data>
class ShaderConstantProfile
class ShaderConstantProfile : public ShaderGeneratorInterface<uid_data>
{
public:
ShaderConstantProfile(int num_constants) { constant_usage.resize(num_constants); }
void Write(const char* fmt, ...) {}
const char* GetBuffer() { return NULL; }
void SetBuffer(char* buffer) { }
uid_data& GetUidData() { return *(uid_data*)NULL; }
// has room for optimization (if it matters at all...)
void NumConstants() { return constant_usage.size(); }