#include "stdafx.h" #include "GetShaderCapabilities.h" #include "CKRasterizer.h" #define GETEFFECTCAPABILITIES_GUID CKGUID(0x53b7731f,0x360737f8) //----------------------------------------------------------------------------- int GetShaderCapabilities_2(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKRenderContext* rc = behcontext.CurrentRenderContext; CKRasterizerContext* rstCtx = NULL; if (rc) rstCtx = rc->GetRasterizerContext(); // Gets the manager. int id = 0; CKShaderManager* fxman = (CKShaderManager*)behcontext.Context->GetManagerByGuid(ShaderManagerGUID); // On if (beh->IsInputActive(0)) { int platform = VXPLATFORM_UNKNOWN; platform = VxGetPlatform(); int rstversion = RSTVERSION_UNKNOWN; int vsProfile = CPL_PROFILE_NONE; int psProfile = CPL_PROFILE_NONE; float vsversion = 0; float psversion = 0; // If the effect manager is available. if (fxman && fxman->IsSupported()) fxman->GetVSPSVersion(vsversion, psversion); if (rstCtx && rstCtx->m_Driver->m_2DCaps.Family == CKRST_DIRECTX) { VxDirectXData* dxdata = NULL; dxdata = rc->GetDirectXInfo(); if (dxdata) { switch(dxdata->DxVersion) { case 0x0900 : rstversion = RSTVERSION_DX9; if(vsversion == 1.1f) vsProfile = CPL_PROFILE_VS_1_1; else if(vsversion == 2.0f) vsProfile = CPL_PROFILE_VS_2_0; else if(vsversion == 3.0f) vsProfile = CPL_PROFILE_VS_3_0; if(psversion == 1.1f) psProfile = CPL_PROFILE_PS_1_1; else if(psversion == 1.3f) psProfile = CPL_PROFILE_PS_1_3; else if(psversion == 1.4f) psProfile = CPL_PROFILE_PS_1_4; else if(psversion == 2.0f) psProfile = CPL_PROFILE_PS_2_0; else if(psversion > 2.0f && psversion < 3.0f) psProfile = CPL_PROFILE_PS_2_0a; else if(psversion == 3.0f) psProfile = CPL_PROFILE_PS_3_0; break; case 0x0801 : rstversion = RSTVERSION_DX8; break; case 0x0800 : rstversion = RSTVERSION_DX8; break; case 0x0700 : rstversion = RSTVERSION_DX7; break; case 0x0500 : rstversion = RSTVERSION_DX5; break; } } } else if (rstCtx && rstCtx->m_Driver->m_2DCaps.Family == CKRST_OPENGL) { rstversion = RSTVERSION_OGL; if(vsversion == 1.1f) vsProfile = CPL_PROFILE_VP20; else if(vsversion == 2.0f) vsProfile = CPL_PROFILE_VP30; else if(vsversion == 3.0f) vsProfile = CPL_PROFILE_VP40; else if(vsversion == 2.1f) vsProfile = CPL_PROFILE_ARBVP1; else if(vsversion == 2.2f) vsProfile = CPL_PROFILE_ARBVP1; // CG_PROFILE_GLSLV if(psversion == 1.1f) psProfile = CPL_PROFILE_FP20; else if(psversion == 2.0f) psProfile = CPL_PROFILE_FP30; else if(psversion == 3.0f) psProfile = CPL_PROFILE_FP40; else if(psversion == 2.1f) psProfile = CPL_PROFILE_ARBFP1; else if(psversion == 2.2f) psProfile = CPL_PROFILE_ARBFP1; // CG_PROFILE_GLSLF } beh->SetOutputParameterValue(PARAMOUT_PLATFORM, &platform); beh->SetOutputParameterValue(PARAMOUT_RSTVERSION, &rstversion); beh->SetOutputParameterValue(PARAMOUT_VSPROFILE, &vsProfile); beh->SetOutputParameterValue(PARAMOUT_PSPROFILE, &psProfile); beh->ActivateOutput(0); } return CKBR_OK; } //----------------------------------------------------------------------------- CKERROR CreateGetShaderCapabilitiesProto_2(CKBehaviorPrototype **pproto) { CKBehaviorPrototype *proto = CreateCKBehaviorPrototype("Get Generic Shader Capabilities"); if(!proto) return CKERR_OUTOFMEMORY; proto->DeclareInput("In"); proto->DeclareOutput("Out"); proto->DeclareOutParameter("Platform", CKPGUID_HOST_PLATFORM); proto->DeclareOutParameter("Rasterizer Version", CKENUMGUID_RASTERIZERVERSION); proto->DeclareOutParameter("Best VS Compilation Profile", CKENUMGUID_COMPILATIONPROFILE); proto->DeclareOutParameter("Best PS Compilation Profile", CKENUMGUID_COMPILATIONPROFILE); proto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL); proto->SetFunction(GetShaderCapabilities_2); *pproto = proto; return CK_OK; } //----------------------------------------------------------------------------- CKObjectDeclaration *FillBehaviorGetShaderCapabilities_2() { CKObjectDeclaration *od = CreateCKObjectDeclaration("Get Generic Shader Capabilities"); od->SetDescription("Gets shaders (HLSL / CGFX) related hardware capabilities"); /* rem: In: triggers the process
Out: is activated when the process is completed.

Material: The material.
Technique: The name of the technique.
Find Next Technique: Finds the next technique from the technique found.
*/ od->SetCategory("Shaders/General"); od->SetType(CKDLL_BEHAVIORPROTOTYPE); od->SetGuid(GETEFFECTCAPABILITIES_GUID); od->SetAuthorGuid(VIRTOOLS_GUID); od->SetAuthorName("Virtools"); od->SetVersion(0x00010000); od->SetCreationFunction(CreateGetShaderCapabilitiesProto_2); od->SetCompatibleClassId(CKCID_BEOBJECT); return od; }