mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Moved some of the new shader uid stuff to a common header file.
This commit is contained in:
@ -21,6 +21,7 @@
|
||||
#include <stdarg.h>
|
||||
#include "XFMemory.h"
|
||||
#include "VideoCommon.h"
|
||||
#include "ShaderGenCommon.h"
|
||||
|
||||
#define SHADER_POSMTX_ATTRIB 1
|
||||
#define SHADER_NORM1_ATTRIB 6
|
||||
@ -81,74 +82,11 @@ struct uid_data
|
||||
} lit_chans[4];
|
||||
};
|
||||
|
||||
typedef ShaderUid<uid_data> VertexShaderUid;
|
||||
typedef ShaderCode<uid_data> VertexShaderCode;
|
||||
|
||||
class ShaderUid
|
||||
{
|
||||
public:
|
||||
ShaderUid()
|
||||
{
|
||||
memset(values, 0, sizeof(values));
|
||||
}
|
||||
|
||||
void Write(const char* fmt, ...) {}
|
||||
const char* GetBuffer() { return NULL; }
|
||||
void SetBuffer(char* buffer) { }
|
||||
|
||||
bool operator == (const ShaderUid& obj) const
|
||||
{
|
||||
return memcmp(this->values, obj.values, sizeof(values)) == 0;
|
||||
}
|
||||
|
||||
// TODO: Store last frame used and order by that? makes much more sense anyway...
|
||||
bool operator < (const ShaderUid& obj) const
|
||||
{
|
||||
for (int i = 0; i < 24; ++i)
|
||||
{
|
||||
if (this->values[i] < obj.values[i])
|
||||
return true;
|
||||
else if (this->values[i] > obj.values[i])
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
uid_data& GetUidData() { return data; }
|
||||
|
||||
private:
|
||||
union
|
||||
{
|
||||
uid_data data;
|
||||
u32 values[24]; // TODO: Length?
|
||||
};
|
||||
};
|
||||
|
||||
class ShaderCode
|
||||
{
|
||||
public:
|
||||
ShaderCode() : buf(NULL), write_ptr(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Write(const char* fmt, ...)
|
||||
{
|
||||
va_list arglist;
|
||||
va_start(arglist, fmt);
|
||||
write_ptr += vsprintf(write_ptr, fmt, arglist);
|
||||
va_end(arglist);
|
||||
}
|
||||
|
||||
const char* GetBuffer() { return buf; }
|
||||
void SetBuffer(char* buffer) { buf = buffer; write_ptr = buffer; }
|
||||
uid_data& GetUidData() { return *(uid_data*)NULL; }
|
||||
|
||||
private:
|
||||
const char* buf;
|
||||
char* write_ptr;
|
||||
};
|
||||
|
||||
void GenerateShaderUid(ShaderUid& object, u32 components, API_TYPE api_type);
|
||||
void GenerateShaderCode(ShaderCode& object, u32 components, API_TYPE api_type);
|
||||
void GetVertexShaderUid(VertexShaderUid& object, u32 components, API_TYPE api_type);
|
||||
void GenerateVertexShaderCode(VertexShaderCode& object, u32 components, API_TYPE api_type);
|
||||
|
||||
|
||||
#endif // GCOGL_VERTEXSHADER_H
|
||||
|
Reference in New Issue
Block a user