ShaderGenCommon: Introduce a common shader generator interface to make stuff less confusing.
This commit is contained in:
parent
3253603ae7
commit
0e31943216
|
@ -26,7 +26,18 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
template<class uid_data>
|
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:
|
public:
|
||||||
ShaderUid()
|
ShaderUid()
|
||||||
|
@ -35,11 +46,6 @@ public:
|
||||||
memset(values, 0, sizeof(values));
|
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
|
bool operator == (const ShaderUid& obj) const
|
||||||
{
|
{
|
||||||
return memcmp(this->values, obj.values, sizeof(values)) == 0;
|
return memcmp(this->values, obj.values, sizeof(values)) == 0;
|
||||||
|
@ -70,7 +76,7 @@ private:
|
||||||
|
|
||||||
// Needs to be a template for hacks...
|
// Needs to be a template for hacks...
|
||||||
template<class uid_data>
|
template<class uid_data>
|
||||||
class ShaderCode
|
class ShaderCode : public ShaderGeneratorInterface<uid_data>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ShaderCode() : buf(NULL), write_ptr(NULL)
|
ShaderCode() : buf(NULL), write_ptr(NULL)
|
||||||
|
@ -88,8 +94,6 @@ public:
|
||||||
|
|
||||||
const char* GetBuffer() { return buf; }
|
const char* GetBuffer() { return buf; }
|
||||||
void SetBuffer(char* buffer) { buf = buffer; write_ptr = buffer; }
|
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:
|
private:
|
||||||
const char* buf;
|
const char* buf;
|
||||||
|
@ -97,16 +101,11 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class uid_data>
|
template<class uid_data>
|
||||||
class ShaderConstantProfile
|
class ShaderConstantProfile : public ShaderGeneratorInterface<uid_data>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ShaderConstantProfile(int num_constants) { constant_usage.resize(num_constants); }
|
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...)
|
// has room for optimization (if it matters at all...)
|
||||||
void NumConstants() { return constant_usage.size(); }
|
void NumConstants() { return constant_usage.size(); }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue