Ejemplo n.º 1
0
void Actor::ExportData(const std::string& path){

	if (!mUniqueID){
		mUniqueID = gUniqueIDGenerator.CreateUniqueID();
	}
	ExportData(path, "Object_" + std::to_string(mUniqueID));
}
Ejemplo n.º 2
0
bool ExportWiiRegionData(const Volume& volume, const std::string& export_filename)
{
  if (volume.GetVolumeType() != Platform::WiiDisc)
    return false;

  return ExportData(volume, PARTITION_NONE, 0x4E000, 0x20, export_filename);
}
Ejemplo n.º 3
0
void Actor::ExportSceneData(const std::string& pass, File& sceneFile){
	ExportData(pass);
	sceneFile.Out(mUniqueID);
	for (auto child : mTransform->Children()){
		child->ExportSceneData(pass, sceneFile);
	}
}
Ejemplo n.º 4
0
bool ExportWiiUnencryptedHeader(const Volume& volume, const std::string& export_filename)
{
  if (volume.GetVolumeType() != Platform::WiiDisc)
    return false;

  return ExportData(volume, PARTITION_NONE, 0, 0x100, export_filename);
}
Ejemplo n.º 5
0
bool ExportBI2Data(const Volume& volume, const Partition& partition,
                   const std::string& export_filename)
{
  if (!IsDisc(volume.GetVolumeType()))
    return false;

  return ExportData(volume, partition, 0x440, 0x2000, export_filename);
}
Ejemplo n.º 6
0
bool ExportTicket(const Volume& volume, const Partition& partition,
                  const std::string& export_filename)
{
  if (volume.GetVolumeType() != Platform::WiiDisc)
    return false;

  return ExportData(volume, PARTITION_NONE, partition.offset, 0x2a4, export_filename);
}
Ejemplo n.º 7
0
bool ExportFile(const Volume& volume, const Partition& partition, const FileInfo* file_info,
                const std::string& export_filename)
{
  if (!file_info || file_info->IsDirectory())
    return false;

  return ExportData(volume, partition, file_info->GetOffset(), file_info->GetSize(),
                    export_filename);
}
void CDlg_VehicleClassification::OnBnClickedExportData()
{
	CFileDialog dlg (FALSE, "*.csv", "*.csv",OFN_HIDEREADONLY | OFN_NOREADONLYRETURN | OFN_LONGNAMES,
		"Data File (*.csv)|*.csv||", NULL);
	if(dlg.DoModal() == IDOK)
	{
			ExportData(dlg.GetPathName ());
	}
	m_pDoc->OpenCSVFileInExcel(dlg.GetPathName ());
}
Ejemplo n.º 9
0
/**
* テクニック解析
*/
BOOL CShaderConverter::ExportTechnique()
{
    VRETURN(_ExportChunkHeader(m_Out, izanagi::shader::SHD_CHUNK_MAGIC_NUMBER_TECH));

    izanagi::shader::S_SHD_TECH_HEADER sTechHeader;
    FILL_ZERO(&sTechHeader, sizeof(sTechHeader));

    // Blank for technique's header.
    izanagi::tool::CIoStreamSeekHelper cSeekHelper(&m_Out);
    VRETURN(_BeginExportChunk(sTechHeader, cSeekHelper));

    UINT nPassPos = 0;

    // テクニック取得
    CGtechnique tech = ::cgGetFirstTechnique(m_pCgEffect);

    if (tech != NULL) {
        while (tech != NULL) {
            izanagi::shader::S_SHD_TECHNIQUE sTech;
            {
                FILL_ZERO(&sTech, sizeof(sTech));

                IZ_PCSTR name = ::cgGetTechniqueName(tech);
                IZ_UINT pos = CStringChunk::GetInstance().Register(name);

                //sTech.name = *(IZ_PCSTR*)(&pos);
                sTech.posName = pos;
                sTech.keyName = izanagi::CKey::GenerateValue(name);
                sTech.numPass = _GetPassNum(tech);
                sTech.posPass = nPassPos;
            }

            nPassPos += sTech.numPass;

            // 出力
            VRETURN(ExportData(sTech));

            tech = ::cgGetNextTechnique(tech);

            sTechHeader.numTechnique++;
        }
    }
    else {
        // テクニックは必ず一つはないといけない
        IZ_ASSERT(FALSE);

        // TODO

        return FALSE;
    }

    VRETURN(_EndExportChunk(sTechHeader, cSeekHelper));

    return TRUE;
}
Ejemplo n.º 10
0
BOOL CShaderConverter::ExportTexture()
{
    VRETURN(_ExportChunkHeader(m_Out, izanagi::shader::SHD_CHUNK_MAGIC_NUMBER_TEX));

    izanagi::shader::S_SHD_TEXTRUE_HEADER sTexHeader;
    FILL_ZERO(&sTexHeader, sizeof(sTexHeader));

    // Blank for texture's header.
    izanagi::tool::CIoStreamSeekHelper cSeekHelper(&m_Out);
    VRETURN(_BeginExportChunk(sTexHeader, cSeekHelper));

    m_TexList.clear();

    CGparameter param = ::cgGetFirstEffectParameter(m_pCgEffect);

    while (param != NULL) {
        if (CParamUtil::IsTexture(param)) {
            izanagi::shader::S_SHD_TEXTURE sTex;
            {
                FILL_ZERO(&sTex, sizeof(sTex));

                CParamUtil::SetNameAndSemantic(sTex, param);

#if 0
                sTex.type = _GetTexTypeFromSemantic(param);

                sTex.ann.isRenderTarget = IZ_TRUE;
                sTex.ann.isDynamic = IZ_FALSE;
                sTex.ann.typeRsc = izanagi::graph::E_GRAPH_RSC_USAGE_STATIC;

                VRETURN(
                    CTextureUtil::SetAnnValue(
                        sTex.ann,
                        param));
#endif
            }

            m_TexList.push_back(param);

            // 出力
            VRETURN(ExportData(sTex));

            sTexHeader.numTexture++;
        }

        param = ::cgGetNextParameter(param);
    }

    VRETURN(_EndExportChunk(sTexHeader, cSeekHelper));

    m_ShdHeader.numTexture = sTexHeader.numTexture;

    return TRUE;
}
Ejemplo n.º 11
0
void MemberClass::ExportHeader(FILE *outfile)
{
	fprintf(outfile, "\n    class %s {\n    private:\n", m_name);

	ExportData(outfile);

	fprintf(outfile, "\n    public:\n");

	ExportMethods(outfile);

	fprintf(outfile, "\n    }; /* class %s */\n", m_name);
}
Ejemplo n.º 12
0
bool ExportFST(const Volume& volume, const Partition& partition, const std::string& export_filename)
{
  if (!IsDisc(volume.GetVolumeType()))
    return false;

  const std::optional<u64> fst_offset = GetFSTOffset(volume, partition);
  const std::optional<u64> fst_size = GetFSTSize(volume, partition);
  if (!fst_offset || !fst_size)
    return false;

  return ExportData(volume, partition, *fst_offset, *fst_size, export_filename);
}
Ejemplo n.º 13
0
bool ExportH3Hashes(const Volume& volume, const Partition& partition,
                    const std::string& export_filename)
{
  if (volume.GetVolumeType() != Platform::WiiDisc)
    return false;

  const std::optional<u64> offset =
      volume.ReadSwappedAndShifted(partition.offset + 0x2b4, PARTITION_NONE);
  if (!offset)
    return false;

  return ExportData(volume, PARTITION_NONE, partition.offset + *offset, 0x18000, export_filename);
}
Ejemplo n.º 14
0
bool ExportTMD(const Volume& volume, const Partition& partition, const std::string& export_filename)
{
  if (volume.GetVolumeType() != Platform::WiiDisc)
    return false;

  const std::optional<u32> size = volume.ReadSwapped<u32>(partition.offset + 0x2a4, PARTITION_NONE);
  const std::optional<u64> offset =
      volume.ReadSwappedAndShifted(partition.offset + 0x2a8, PARTITION_NONE);
  if (!size || !offset)
    return false;

  return ExportData(volume, PARTITION_NONE, partition.offset + *offset, *size, export_filename);
}
Ejemplo n.º 15
0
bool ExportDOL(const Volume& volume, const Partition& partition, const std::string& export_filename)
{
  if (!IsDisc(volume.GetVolumeType()))
    return false;

  const std::optional<u64> dol_offset = GetBootDOLOffset(volume, partition);
  if (!dol_offset)
    return false;
  const std::optional<u32> dol_size = GetBootDOLSize(volume, partition, *dol_offset);
  if (!dol_size)
    return false;

  return ExportData(volume, partition, *dol_offset, *dol_size, export_filename);
}
Ejemplo n.º 16
0
bool ExportApploader(const Volume& volume, const Partition& partition,
                     const std::string& export_filename)
{
  if (!IsDisc(volume.GetVolumeType()))
    return false;

  std::optional<u32> apploader_size = volume.ReadSwapped<u32>(0x2440 + 0x14, partition);
  const std::optional<u32> trailer_size = volume.ReadSwapped<u32>(0x2440 + 0x18, partition);
  constexpr u32 header_size = 0x20;
  if (!apploader_size || !trailer_size)
    return false;
  *apploader_size += *trailer_size + header_size;
  DEBUG_LOG(DISCIO, "Apploader size -> %x", *apploader_size);

  return ExportData(volume, partition, 0x2440, *apploader_size, export_filename);
}
Ejemplo n.º 17
0
/**
* テクニック解析
*/
BOOL CPostEffectConverter::ExportTechnique()
{
    UINT nPassPos = 0;

    // テクニック取得
    CGtechnique tech = ::cgGetFirstTechnique(m_pCgEffect);

    if (tech != NULL) {
        while (tech != NULL) {
            izanagi::S_PES_TECHNIQUE sTech;
            {
                FILL_ZERO(&sTech, sizeof(sTech));

                IZ_PCSTR name = ::cgGetTechniqueName(tech);
                IZ_UINT pos = CStringChunk::GetInstance().Register(name);

                //sTech.name = *(IZ_PCSTR*)(&pos);
                sTech.posName = pos;
                sTech.keyName = izanagi::CKey::GenerateValue(name);
                sTech.numPass = _GetPassNum(tech);
                sTech.posPass = nPassPos;
            }

            nPassPos += sTech.numPass;

            // 出力
            VRETURN(ExportData(sTech));

            tech = ::cgGetNextTechnique(tech);

            m_PesHeader.numTech++;
        }
    }
    else {
        // テクニックは必ず一つはないといけない
        IZ_ASSERT(FALSE);

        // TODO

        return FALSE;
    }

    return TRUE;
}
Ejemplo n.º 18
0
BOOL CPostEffectConverter::ExportTexture()
{
    m_TexList.clear();

    CGparameter param = ::cgGetFirstEffectParameter(m_pCgEffect);

    while (param != NULL) {
        if (CParamUtil::IsTexture(param)) {
            izanagi::S_PES_TEXTURE sTex;
            {
                FILL_ZERO(&sTex, sizeof(sTex));

                CParamUtil::SetNameAndSemantic(sTex, param);

                sTex.type = _GetTexTypeFromSemantic(param);

                sTex.ann.isRenderTarget = IZ_TRUE;
                sTex.ann.isDynamic = IZ_FALSE;
                sTex.ann.typeRsc = izanagi::graph::E_GRAPH_RSC_USAGE_STATIC;

                VRETURN(
                    CTextureUtil::SetAnnValue(
                        sTex.ann,
                        param));
            }

            m_TexList.push_back(param);

            // 出力
            VRETURN(ExportData(sTex));

            m_PesHeader.numTex++;
        }

        param = ::cgGetNextParameter(param);
    }

    return TRUE;
}
Ejemplo n.º 19
0
BOOL CPostEffectConverter::ExportParamAnn(
    izanagi::S_PES_PARAM_HEADER& paramHader,
    IZ_INT nAnnNum/*= -1*/)
{
    IZ_UINT nAnnCnt = 0;

    // For annotation.
    std::vector<CGparameter>::iterator it = m_ParamList.begin();

    for (; it != m_ParamList.end(); it++) {
        CGparameter param = *it;

        if (CParamUtil::HasAnn(param)) {
            izanagi::S_PES_PARAM_ANN sAnn;
            
            FILL_ZERO(&sAnn, sizeof(sAnn));

            VRETURN(
                CParamUtil::SetAnnValue(
                    sAnn,
                    param));

            // 出力
            VRETURN(ExportData(sAnn));

            nAnnCnt++;
        }
    }

    BOOL ret = (nAnnNum >= 0
                ? (nAnnCnt == nAnnNum)
                : TRUE);

    paramHader.numParamAnn = nAnnCnt;

    IZ_ASSERT(ret);
    return ret;
}
Ejemplo n.º 20
0
// パス解析
BOOL CPostEffectConverter::ExportPass()
{
    IZ_UINT nTechIdx = 0;
    IZ_UINT nPassIdx = 0;

    IZ_UINT nConstNum = 0;
    IZ_UINT nSamplerNum = 0;

    izanagi::tool::CString strPrevPassFunctoName;

    CGtechnique tech = ::cgGetFirstTechnique(m_pCgEffect);

    while (tech != NULL) {
        CGpass pass = ::cgGetFirstPass(tech);
        while (pass != NULL) {
            izanagi::S_PES_PASS sPass;
            {
                FILL_ZERO(&sPass, sizeof(sPass));

                IZ_PCSTR name = ::cgGetPassName(pass);
                IZ_UINT pos = CStringChunk::GetInstance().Register(name);

                //sPass.name = *(IZ_PCSTR*)(&pos);
                sPass.posName = pos;
                sPass.keyName = izanagi::CKey::GenerateValue(name);
                sPass.TechniqueIdx = nTechIdx;
                sPass.numConst = _GetUsedParamNum(m_ParamList, pass);
                sPass.numSampler = _GetUsedParamNum(m_SamplerList, pass);
                VRETURN(CPassUtil::SetVSType(sPass, pass));

                sPass.sizeProgram = _GetFileSize(m_CompiledPSList[nPassIdx]);

                sPass.ann.RenderTargetIdx = _GetRenderTargetIdx(m_TexList, pass);
                sPass.ann.TexOffsetParamIdx = _GetTexOffsetParamIdx(m_ParamList, pass);

                for (IZ_UINT i = 0; i < izanagi::PES_FUNCTOR_ARGS_NUM; i++) {
                    sPass.ann.FunctorArgs[i] = -1;
                }

                nConstNum += sPass.numConst;
                nSamplerNum += sPass.numSampler;
            }

            VRETURN(
                CPassUtil::SetAnnValue(
                    sPass.ann,
                    pass));

            IZ_PCSTR pszFunctorName = CPassUtil::GetFunctorName(pass);

            if (pszFunctorName != IZ_NULL) {
                if (strPrevPassFunctoName == pszFunctorName) {
                    sPass.ann.isSubPass = IZ_TRUE;
                }

                strPrevPassFunctoName = pszFunctorName;
            }

            // Stringで設定されているファンクタ引数
            std::vector<izanagi::tool::CString> tvFunctorArgSList;
            CPassUtil::GetFunctorArgsString(
                pass,
                tvFunctorArgSList);

            if (tvFunctorArgSList.size() > 0) {
                ConvertFunctorArgsStrToIndex(
                    tvFunctorArgSList,
                    sPass.ann);
            }

            VRETURN(
                CPassUtil::SetStateValue(
                    sPass.state,
                    pass));

            // 出力
            VRETURN(ExportData(sPass));

            pass = ::cgGetNextPass(pass);
            nPassIdx++;

            m_PesHeader.maxProgamSize = IZ_MAX(m_PesHeader.maxProgamSize, sPass.sizeProgram);
            m_PesHeader.numPass++;
        }

        tech = ::cgGetNextTechnique(tech);
        nTechIdx++;
    }

    // NOTE
    // 全体でのシェーダ定数、サンプラの総数を知りたい
    m_PesHeader.numParam = nConstNum;
    m_PesHeader.numSampler = nSamplerNum;

    return TRUE;
}
Ejemplo n.º 21
0
/**
* パラメータ解析
*/
BOOL CPostEffectConverter::ExportParameter()
{
    IZ_UINT nAnnIdx = 0;

    izanagi::S_PES_PARAM_HEADER paramHader;
    {
        paramHader.numParameter = 0;
        paramHader.numParamAnn = 0;
    }

    // Blank for pass's header.
    izanagi::tool::CIoStreamSeekHelper cSeekHelper(&m_Out);
    VRETURN(cSeekHelper.Skip(sizeof(paramHader)));

    // For description.
    CGparameter param = ::cgGetFirstEffectParameter(m_pCgEffect);

    while (param != NULL) {
        if (CParamUtil::IsParameter(param)
            && !_IgnoreParameter(param))
        {
            // For Debug...
            IZ_PCSTR name = ::cgGetParameterName(param);

            VRETURN(CParamUtil::IsValidParameter(param));

            izanagi::S_PES_PARAMETER sParam;
            FILL_ZERO(&sParam, sizeof(sParam));
            
            sParam.DoNotStrip = CParamUtil::DoNotStrip(param);
            
            if (sParam.DoNotStrip
                || DoNotRemoveParam(param))
            {
                CParamUtil::SetNameAndSemantic(sParam, param);

                VRETURN(
                    CParamUtil::SetDescValue(
                        sParam,
                        param));

                if (sParam.hasAnn) {
                    sParam.AnnotationIdx = nAnnIdx++;
                }

                // Register initial value.
                VRETURN(
                    CParamUtil::GetInitValue(
                        sParam,
                        param));

                m_ParamList.push_back(param);

                // 出力
                VRETURN(ExportData(sParam));

                paramHader.numParameter++;
            }
        }

        param = ::cgGetNextParameter(param);
    }

    VRETURN(ExportParamAnn(paramHader, nAnnIdx));

    // Export initial value.
    m_PesHeader.sizeValueBuffer = CDataBuffer::GetInstance().GetBufferSize();
    if (m_PesHeader.sizeValueBuffer > 0) {
        const void* pBuf = CDataBuffer::GetInstance().GetBuffer();

        IZ_OUTPUT_WRITE_VRETURN(
            &m_Out,
            pBuf,
            0,
            m_PesHeader.sizeValueBuffer);
    }

    // Return to paremter's header position with anchor.
    VRETURN(cSeekHelper.ReturnWithAnchor());

    // Export paramter's header.
    IZ_OUTPUT_WRITE_VRETURN(&m_Out, &paramHader, 0, sizeof(paramHader));

    // Return to anchored position.
    VRETURN(cSeekHelper.ReturnToAnchor());

    return TRUE;
}
Ejemplo n.º 22
0
BOOL CPostEffectConverter::ExportSampler()
{
    izanagi::S_PES_SAMPLER_HEADER smplHeader;
    {
        smplHeader.numSampler = 0;
    }

    // Blank for pass's header.
    izanagi::tool::CIoStreamSeekHelper cSeekHelper(&m_Out);
    VRETURN(cSeekHelper.Skip(sizeof(smplHeader)));

    // パスを取得
    std::vector<CGpass> passList;
    {
        CGtechnique tech = ::cgGetFirstTechnique(m_pCgEffect);
        while (tech != NULL) {
            CGpass pass = ::cgGetFirstPass(tech);
            while (pass != NULL) {
                passList.push_back(pass);
                pass = ::cgGetNextPass(pass);
            }
            tech = ::cgGetNextTechnique(tech);
        }
    }

    CGparameter param = ::cgGetFirstEffectParameter(m_pCgEffect);

    while (param != NULL) {
        if (::cgIsParameterUsed(param, m_pCgEffect)) {
            VRETURN(CParamUtil::IsValidParameter(param));

            if (CParamUtil::IsSampler(param)) {
                // 対象となるパスのインデックスを取得
                IZ_INT passIdx = -1;
                for (IZ_UINT i = 0; i < passList.size(); i++) {
                    if (::cgIsParameterUsed(param, passList[i])) {
                        passIdx = i;
                        break;
                    }
                }

                izanagi::S_PES_SAMPLER sSampler;
                {
                    FILL_ZERO(&sSampler, sizeof(sSampler));

                    sSampler.state.minFilter = izanagi::graph::E_GRAPH_TEX_FILTER_LINEAR;
                    sSampler.state.magFilter = izanagi::graph::E_GRAPH_TEX_FILTER_LINEAR;
                    sSampler.state.addrU = izanagi::graph::E_GRAPH_TEX_ADDRESS_CLAMP;
                    sSampler.state.addrV = izanagi::graph::E_GRAPH_TEX_ADDRESS_CLAMP;

                    CParamUtil::SetNameAndSemantic(sSampler, param);
                    
                    VRETURN(
                        CSamplerUtil::SetStateValue(
                            sSampler.state,
                            param));

                    // 対象となるテクスチャとのバインド情報を設定
                    VRETURN(
                        CSamplerUtil::BindTexture(
                            sSampler.state,
                            param,
                            m_TexList));

                    if (passIdx >= 0) {
                        // シェーダ定数テーブルを作成
                        IZ_ASSERT(passIdx < m_CompiledPSList.size());

                        izanagi::tool::CSimpleMemoryAllocator allocator;

                        izanagi::tool::CShaderConstTableLite* constTbl = izanagi::tool::CShaderConstTableLite::CreateShaderConstTableLite(
                            &allocator,
                            m_CompiledPSList[passIdx]);

                        const char* paramName = ::cgGetParameterName(param);

                        sSampler.resource_id = constTbl->GetSamplerIndex(paramName);

                        SAFE_RELEASE(constTbl);
                    }
                    else {
                        // ある?
                        sSampler.resource_id = -1;
                    }
                }

                m_SamplerList.push_back(param);

                // 出力
                VRETURN(ExportData(sSampler));

                smplHeader.numSampler++;
            }
        }

        param = ::cgGetNextParameter(param);
    }

    // Return to paremter's header position with anchor.
    VRETURN(cSeekHelper.ReturnWithAnchor());

    // Export paramter's header.
    IZ_OUTPUT_WRITE_VRETURN(&m_Out, &smplHeader, 0, sizeof(smplHeader));

    // Return to anchored position.
    VRETURN(cSeekHelper.ReturnToAnchor());

    return TRUE;
}
Ejemplo n.º 23
0
// パス解析
BOOL CShaderConverter::ExportPass(const SShaderConfig& config)
{
    _ExportChunkHeader(m_Out, izanagi::shader::SHD_CHUNK_MAGIC_NUMBER_PASS);

    izanagi::shader::S_SHD_PASS_HEADER sPassHeader;
    FILL_ZERO(&sPassHeader, sizeof(sPassHeader));

    // Blank for pass's header.
    izanagi::tool::CIoStreamSeekHelper cSeekHelper(&m_Out);
    VRETURN(_BeginExportChunk(sPassHeader, cSeekHelper));

    IZ_UINT nTechIdx = 0;
    IZ_UINT nPassIdx = 0;

    IZ_UINT nConstNum = 0;
    IZ_UINT nSamplerNum = 0;

    CGtechnique tech = ::cgGetFirstTechnique(m_pCgEffect);

    while (tech != NULL) {
        CGpass pass = ::cgGetFirstPass(tech);
        while (pass != NULL) {
            izanagi::shader::S_SHD_PASS sPass;
            {
                FILL_ZERO(&sPass, sizeof(sPass));

                IZ_PCSTR name = ::cgGetPassName(pass);
                IZ_UINT pos = CStringChunk::GetInstance().Register(name);

                //sPass.name = *(IZ_PCSTR*)(&pos);
                sPass.posName = pos;
                sPass.keyName = izanagi::CKey::GenerateValue(name);

                sPass.TechniqueIdx = nTechIdx;

                sPass.numConst = _GetUsedParamNum(m_ParamList, pass);
                sPass.numSampler = _GetUsedParamNum(m_SamplerList, pass);

                sPass.sizeVS = _GetFileSize(config, m_CompiledVSList[nPassIdx]);
                sPass.sizePS = _GetFileSize(config, m_CompiledPSList[nPassIdx]);

                nConstNum += sPass.numConst;
                nSamplerNum += sPass.numSampler;
            }

            VRETURN(
                CPassUtil::SetStateValue(
                    sPass.state,
                    pass));

            // 出力
            VRETURN(ExportData(sPass));

            pass = ::cgGetNextPass(pass);
            nPassIdx++;

            IZ_UINT nMax = IZ_MAX(sPass.sizeVS, sPass.sizePS);

            m_ShdHeader.maxProgamSize = IZ_MAX(m_ShdHeader.maxProgamSize, nMax);

            sPassHeader.numPass++;
        }

        tech = ::cgGetNextTechnique(tech);
        nTechIdx++;
    }

    m_ShdHeader.numPass = sPassHeader.numPass;

    // NOTE
    // 全体でのシェーダ定数、サンプラの総数を知りたい

    m_ShdHeader.numParam = nConstNum;
    m_ShdHeader.numSmpl = nSamplerNum;

    VRETURN(ExportUsedParamAndSamplerIdxByPass());

    VRETURN(_EndExportChunk(sPassHeader, cSeekHelper));

    return TRUE;
}
Ejemplo n.º 24
0
/**
* パラメータ解析
*/
BOOL CShaderConverter::ExportParameter(const SShaderConfig& config)
{
    _ExportChunkHeader(m_Out, izanagi::shader::SHD_CHUNK_MAGIC_NUMBER_PARAM);

    izanagi::shader::S_SHD_PARAM_HEADER sParamHeader;
    FILL_ZERO(&sParamHeader, sizeof(sParamHeader));

    // Blank for parameter's header.
    izanagi::tool::CIoStreamSeekHelper cSeekHelper(&m_Out);
    VRETURN(_BeginExportChunk(sParamHeader, cSeekHelper));

    IZ_UINT nAnnIdx = 0;

    // For description.
    CGparameter param = ::cgGetFirstEffectParameter(m_pCgEffect);

    while (param != NULL) {
        if (CParamUtil::IsParameter(param))
        {
            // For Debug...
            IZ_PCSTR name = ::cgGetParameterName(param);

            VRETURN(CParamUtil::IsValidParameter(param));

            izanagi::shader::S_SHD_PARAMETER sParam;
            FILL_ZERO(&sParam, sizeof(sParam));

            sParam.DoNotStrip = CParamUtil::DoNotStrip(param);
            BOOL bIsUsedInEffect = ::cgIsParameterUsed(param, m_pCgEffect);

#if 0
            if (sParam.DoNotStrip
                    || DoNotRemoveParam(param))
#else
            if (bIsUsedInEffect || sParam.DoNotStrip)
#endif
            {
                CParamUtil::SetNameAndSemantic(sParam, param);

                VRETURN(
                    CParamUtil::SetDescValue(
                        config,
                        sParam,
                        param));

                if (sParam.hasAnn) {
                    sParam.AnnotationIdx = nAnnIdx++;
                }

                // Register initial value.
                VRETURN(
                    CParamUtil::GetInitValue(
                        sParam,
                        param));

                if (config.type == izanagi::E_PLATFORM_GLES2) {
                    // For GLES2
#if 0
                    if (izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT1x1 <= sParam.Type
                            && sParam.Type <= izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT4x4)
                    {
                        // TODO
                        sParam.Type = izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT4;
                        sParam.Elements = (sParam.Elements > 0 ? sParam.Elements * 4 : 4);
                    }
#else
                    switch (sParam.Type) {
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT1x1:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT1x2:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT1x3:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT1x4:
                        sParam.Type = izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT;
                        //sParam.Elements = (sParam.Elements > 0 ? sParam.Elements * 1 : 1);
                        break;
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT2x1:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT2x2:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT2x3:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT2x4:
                        sParam.Type = izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT2;
                        //sParam.Elements = (sParam.Elements > 0 ? sParam.Elements * 2 : 2);
                        break;
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT3x1:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT3x2:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT3x3:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT3x4:
                        sParam.Type = izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT3;
                        //sParam.Elements = (sParam.Elements > 0 ? sParam.Elements * 3 : 3);
                        break;
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT4x1:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT4x2:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT4x3:
                    case izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT4x4:
                        sParam.Type = izanagi::shader::E_SHADER_PARAMETER_TYPE_FLOAT4;
                        //sParam.Elements = (sParam.Elements > 0 ? sParam.Elements * 4 : 4);
                        break;
                    }

                    //printf("    Rows(%d) Columns(%d) Elements(%d)\n", sParam.Rows, sParam.Columns, sParam.Elements);
#endif
                }

                m_ParamList.push_back(param);

                // 出力
                VRETURN(ExportData(sParam));

                sParamHeader.numParameter++;
            }
        }

        param = ::cgGetNextParameter(param);
    }

    VRETURN(ExportParamAnn(sParamHeader, nAnnIdx));

    // Export initial value.
    sParamHeader.sizeValueBuffer = CDataBuffer::GetInstance().GetBufferSize();
    if (sParamHeader.sizeValueBuffer > 0) {
        const void* pBuf = CDataBuffer::GetInstance().GetBuffer();

        IZ_OUTPUT_WRITE_VRETURN(
            &m_Out,
            pBuf,
            0,
            sParamHeader.sizeValueBuffer);
    }

    //m_ShdHeader.numParam = sParamHeader.numParameter;

    VRETURN(_EndExportChunk(sParamHeader, cSeekHelper));

    return TRUE;
}
Ejemplo n.º 25
0
BOOL CShaderConverter::ExportSampler(const SShaderConfig& config)
{
    VRETURN(_ExportChunkHeader(m_Out, izanagi::shader::SHD_CHUNK_MAGIC_NUMBER_SMPL));

    izanagi::shader::S_SHD_SAMPLER_HEADER sSmplHeader;
    FILL_ZERO(&sSmplHeader, sizeof(sSmplHeader));

    // Blank for texture's header.
    izanagi::tool::CIoStreamSeekHelper cSeekHelper(&m_Out);
    VRETURN(_BeginExportChunk(sSmplHeader, cSeekHelper));

    CGparameter param = ::cgGetFirstEffectParameter(m_pCgEffect);

    // パスを取得
    std::vector<CGpass> passList;
    {
        CGtechnique tech = ::cgGetFirstTechnique(m_pCgEffect);
        while (tech != NULL) {
            CGpass pass = ::cgGetFirstPass(tech);
            while (pass != NULL) {
                passList.push_back(pass);
                pass = ::cgGetNextPass(pass);
            }
            tech = ::cgGetNextTechnique(tech);
        }
    }

    while (param != NULL) {
        if (::cgIsParameterUsed(param, m_pCgEffect)) {
            VRETURN(CParamUtil::IsValidParameter(param));

            if (CParamUtil::IsSampler(param)) {
                // 対象となるパスのインデックスを取得
                IZ_INT passIdx = -1;
                for (IZ_UINT i = 0; i < passList.size(); i++) {
                    if (::cgIsParameterUsed(param, passList[i])) {
                        passIdx = i;
                        break;
                    }
                }

                izanagi::shader::S_SHD_SAMPLER sSampler;
                {
                    FILL_ZERO(&sSampler, sizeof(sSampler));

                    sSampler.state.minFilter = izanagi::graph::E_GRAPH_TEX_FILTER_LINEAR;
                    sSampler.state.magFilter = izanagi::graph::E_GRAPH_TEX_FILTER_LINEAR;
                    sSampler.state.mipFilter = izanagi::graph::E_GRAPH_TEX_FILTER_LINEAR;
                    sSampler.state.addressU = izanagi::graph::E_GRAPH_TEX_ADDRESS_CLAMP;
                    sSampler.state.addressV = izanagi::graph::E_GRAPH_TEX_ADDRESS_CLAMP;

                    CParamUtil::SetNameAndSemantic(sSampler, param);

                    CGtype type = CParamUtil::GetCgType(param);
                    sSampler.Type = CShaderConvUtil::CgParamTypeToIzanagiShaderParamType(type);

                    VRETURN(
                        CSamplerUtil::SetStateValue(
                            sSampler,
                            param));

                    // 対象となるテクスチャとのバインド情報を設定
                    VRETURN(
                        CSamplerUtil::BindTexture(
                            sSampler,
                            param,
                            m_TexList));

                    if (passIdx >= 0) {
                        // シェーダ定数テーブルを作成
                        IZ_ASSERT(passIdx < m_CompiledPSList.size());

                        if (config.type == izanagi::E_PLATFORM_DX9)
                        {
                            izanagi::tool::CSimpleMemoryAllocator allocator;

                            // ピクセルシェーダを読み込む
                            izanagi::tool::CShaderConstTableLite* constTbl = izanagi::tool::CShaderConstTableLite::CreateShaderConstTableLite(
                                        &allocator,
                                        m_CompiledPSList[passIdx].c_str());

                            const char* paramName = ::cgGetParameterName(param);

                            // シェーダからサンプラのインデックスを取得
                            sSampler.resource_id = constTbl->GetSamplerIndex(paramName);

                            SAFE_RELEASE(constTbl);
                        }
                        else if (config.type == izanagi::E_PLATFORM_GLES2)
                        {
                            const char* paramName = ::cgGetParameterName(param);

                            // ShaderCompilerに任せる
                            izanagi::tool::CString command;
                            command.format(
                                "%s --analyze %s %s\0",
                                config.compiler.c_str(),
                                m_CompiledPSList[passIdx].c_str(),
                                paramName);

                            // ShaderCompilerを起動
                            FILE* fp = _popen(command.c_str(), "r");
                            VRETURN(fp != NULL);

                            static char buf[4];

                            // 標準出力に出力された数値を取得
                            while(fgets(buf, sizeof(buf), fp) != NULL)
                            {
                                int index = ::atoi(buf);
                                sSampler.resource_id = index;
                            }

                            int result = _pclose(fp);
                            VRETURN(result == 0);
                        }
                        else
                        {
                            IZ_ASSERT(IZ_FALSE);
                        }
                    }
                    else {
                        // ある?
                        sSampler.resource_id = -1;
                    }
                }

                m_SamplerList.push_back(param);

                // 出力
                VRETURN(ExportData(sSampler));

                sSmplHeader.numSampler++;
            }
        }

        param = ::cgGetNextParameter(param);
    }

    //m_ShdHeader.numSmpl = sSmplHeader.numSampler;

    VRETURN(_EndExportChunk(sSmplHeader, cSeekHelper));

    return TRUE;
}
Ejemplo n.º 26
0
LRESULT CMemoryView::OnInfoProc(WPARAM wParam, LPARAM lParam){
	
	
	ePipeline* Info = (ePipeline*)wParam;
	
	int64 Type = Info->PopInt();
	int64 Cmd  = Info->PopInt();
	
	if (Type == INSTANCE_OBJECT)
	{
		if(Cmd == CREATE_INSTANCE){
			ePipeline* ObjData = (ePipeline*)Info->GetData(0);
			CreateObjectInstance(ObjData);
		}else if (Cmd == NAME_INSTANCE)
		{
			tstring SrceObjectName = Info->PopString();
			int64 InstanceID = Info->PopInt();
			tstring InstanceName = Info->PopString();
			NameObjectInstance(SrceObjectName,InstanceID,InstanceName);

		}else if (Cmd == CLOSE_INSTANCE)
		{
			tstring SrceObjectName = Info->PopString();
			int64 InstanceID = Info->PopInt();
			CloseObjectInstance(SrceObjectName,InstanceID);
		}
	} 
	else if(Type == INSTANCE_DATA)
	{
		switch(Cmd){
		case CREATE_INSTANCE:
			{
				tstring InstanceName = Info->PopString();
				CreateDataInstance(InstanceName);
			}
			break;
		case INSERT_DATA:
			{
				tstring InstanceName = Info->PopString();
				int32 Index = Info->PopInt();

				ePipeline* Data = (ePipeline*)Info->GetData(0);

				InsertData(InstanceName,Index,Data);
			}
			break;
		case MODIFY_DATA:
			{
				tstring InstanceName = Info->PopString();
				int32 Index = Info->PopInt();

				ePipeline* Data = (ePipeline*)Info->GetData(0);

				ModifyData(InstanceName,Index,Data);

			}
			break;
		case REMOVE_DATA:
			{
				tstring InstanceName = Info->PopString();
				int32 Index = Info->PopInt();
				RemoveData(InstanceName,Index);
			}
			break;
		case CLOSE_INSTANCE:
			{
				tstring InstanceName = Info->PopString();
				CloseDataInstance(InstanceName);
			}
			break;
		case IMPORT_DATA:
			{
				tstring InstanceName = Info->PopString();
				ePipeline* DataList = (ePipeline*)Info->GetData(0);
				ImportData(InstanceName,DataList);
			}
			break;
		case EXPORT_DATA:
			{
				tstring InstanceName = Info->PopString();
				ExportData(InstanceName);
			}
			break;
		default:
			assert(0);
			break;
		}
	}
	m_Toolbar.m_Owner = NULL;
	m_SpaceSelected = NULL;
	m_SpaceFocused  = NULL;
	Layout();
	return 0;	
}
Ejemplo n.º 27
0
void OpenSessionInPutty(const UnicodeString & PuttyPath,
  TSessionData * SessionData)
{
  UnicodeString Program, Params, Dir;
  SplitCommand(PuttyPath, Program, Params, Dir);
  Program = ExpandEnvironmentVariables(Program);
  if (FindFile(Program))
  {
    Params = ExpandEnvironmentVariables(Params);
    UnicodeString Password = GetGUIConfiguration()->GetPuttyPassword() ? SessionData->GetPassword() : UnicodeString();
    UnicodeString Psw = Password;
    UnicodeString SessionName;
    std::unique_ptr<TRegistryStorage> Storage(new TRegistryStorage(GetConfiguration()->GetPuttySessionsKey()));
    Storage->SetAccessMode(smReadWrite);
    // make it compatible with putty
    Storage->SetMungeStringValues(false);
    Storage->SetForceAnsi(true);
    if (Storage->OpenRootKey(true))
    {
      if (Storage->KeyExists(SessionData->GetStorageKey()))
      {
        SessionName = SessionData->GetSessionName();
      }
      else
      {
        std::unique_ptr<TRegistryStorage> SourceStorage(new TRegistryStorage(GetConfiguration()->GetPuttySessionsKey()));
        SourceStorage->SetMungeStringValues(false);
        SourceStorage->SetForceAnsi(true);
        if (SourceStorage->OpenSubKey(StoredSessions->GetDefaultSettings()->GetName(), false) &&
            Storage->OpenSubKey(GetGUIConfiguration()->GetPuttySession(), true))
        {
          Storage->Copy(SourceStorage.get());
          Storage->CloseSubKey();
        }

        std::unique_ptr<TSessionData> ExportData(new TSessionData(L""));
        ExportData->Assign(SessionData);
        ExportData->SetModified(true);
        ExportData->SetName(GetGUIConfiguration()->GetPuttySession());
        ExportData->SetPassword(L"");

        if (SessionData->GetFSProtocol() == fsFTP)
        {
          if (GetGUIConfiguration()->GetTelnetForFtpInPutty())
          {
            ExportData->SetPuttyProtocol(PuttyTelnetProtocol);
            ExportData->SetPortNumber(TelnetPortNumber);
            // PuTTY  does not allow -pw for telnet
            Psw.Clear();
          }
          else
          {
            ExportData->SetPuttyProtocol(PuttySshProtocol);
            ExportData->SetPortNumber(SshPortNumber);
          }
        }

        ExportData->Save(Storage.get(), true);
        SessionName = GetGUIConfiguration()->GetPuttySession();
      }
    }

    if (!Params.IsEmpty())
    {
      Params += L" ";
    }
    if (!Psw.IsEmpty())
    {
      Params += FORMAT(L"-pw %s ", EscapePuttyCommandParam(Psw).c_str());
    }
    //Params += FORMAT(L"-load %s", EscapePuttyCommandParam(SessionName).c_str());
    Params += FORMAT(L"-l %s ", EscapePuttyCommandParam(SessionData->GetUserNameExpanded()).c_str());
    Params += FORMAT(L"-P %d ", SessionData->GetPortNumber());
    Params += FORMAT(L"%s ", EscapePuttyCommandParam(SessionData->GetHostNameExpanded()).c_str());

    if (!ExecuteShell(Program, Params))
    {
      throw Exception(FMTLOAD(EXECUTE_APP_ERROR, Program.c_str()));
    }
  }
  else
  {
    throw Exception(FMTLOAD(FILE_NOT_FOUND, Program.c_str()));
  }
}