From 0e319432164ef0c906e947a2c54fa51739d00e7c Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Tue, 26 Mar 2013 23:03:10 +0100 Subject: [PATCH] ShaderGenCommon: Introduce a common shader generator interface to make stuff less confusing. --- Source/Core/VideoCommon/Src/ShaderGenCommon.h | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/Source/Core/VideoCommon/Src/ShaderGenCommon.h b/Source/Core/VideoCommon/Src/ShaderGenCommon.h index e052066628..d02462360d 100644 --- a/Source/Core/VideoCommon/Src/ShaderGenCommon.h +++ b/Source/Core/VideoCommon/Src/ShaderGenCommon.h @@ -26,7 +26,18 @@ #include template -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 ShaderUid : public ShaderGeneratorInterface { 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 ShaderCode +class ShaderCode : public ShaderGeneratorInterface { 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 ShaderConstantProfile +class ShaderConstantProfile : public ShaderGeneratorInterface { 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(); }