Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CS_SHADERPLUGIN_H__
00020 #define __CS_SHADERPLUGIN_H__
00021
00026 #include "csutil/scf.h"
00027 #include "csutil/strhash.h"
00028
00029 #include "ivideo/shader/shader.h"
00030
00031 struct iString;
00032
00036
00037 struct csShaderVarMapping
00038 {
00040 CS::ShaderVarStringID name;
00042 csString destination;
00043 csShaderVarMapping (CS::ShaderVarStringID n, const char* d) : name(n),
00044 destination(d) {}
00045 };
00046
00047
00052 struct iShaderDestinationResolver : public virtual iBase
00053 {
00054 SCF_INTERFACE(iShaderDestinationResolver, 0,0,1);
00059 virtual int ResolveTU (const char* binding) = 0;
00060
00061 virtual csVertexAttrib ResolveBufferDestination (const char* binding) = 0;
00062 };
00063
00068 struct iShaderProgram : public virtual iBase
00069 {
00070 SCF_INTERFACE(iShaderProgram, 7, 0, 0);
00072 virtual void Activate() = 0;
00073
00075 virtual void Deactivate() = 0;
00076
00078 virtual void SetupState (const CS::Graphics::RenderMesh* mesh,
00079 CS::Graphics::RenderMeshModes& modes,
00080 const csShaderVariableStack& stack) = 0;
00081
00083 virtual void ResetState () = 0;
00084
00086 virtual bool Load (iShaderDestinationResolver* resolve,
00087 iDocumentNode* node) = 0;
00088
00090 virtual bool Load (iShaderDestinationResolver* resolve, const char* program,
00091 csArray<csShaderVarMapping>& mappings) = 0;
00092
00100 virtual bool Compile (iHierarchicalCache* cacheTo,
00101 csRef<iString>* cacheTag = 0) = 0;
00102
00115 virtual void GetUsedShaderVars (csBitArray& bits) const = 0;
00116
00117 enum CacheLoadResult
00118 {
00119 loadFail,
00120 loadSuccessShaderInvalid,
00121 loadSuccessShaderValid
00122 };
00124 virtual CacheLoadResult LoadFromCache (iHierarchicalCache* cache,
00125 iBase* previous, iDocumentNode* programNode,
00126 csRef<iString>* failReason = 0, csRef<iString>* cacheTag = 0) = 0;
00127 };
00128
00133 struct iShaderProgramPlugin : public virtual iBase
00134 {
00135 SCF_INTERFACE(iShaderProgramPlugin,3,0,0);
00136 virtual csPtr<iShaderProgram> CreateProgram (const char* type) = 0;
00137 virtual bool SupportType (const char* type) = 0;
00138
00139 virtual csPtr<iStringArray> QueryPrecacheTags (const char* type) = 0;
00144 virtual bool Precache (const char* type, const char* tag,
00145 iBase* previous, iDocumentNode* node,
00146 iHierarchicalCache* cacheTo, csRef<iBase>* outObj = 0) = 0;
00147 };
00148
00151 #endif
00152