/** * レンダーターゲット作成 */ CRenderTarget* CGraphicsDeviceDX9::CreateRenderTarget( IZ_UINT width, IZ_UINT height, E_GRAPH_PIXEL_FMT fmt) { CRenderTargetDX9* pRT = IZ_NULL; if (fmt == E_GRAPH_PIXEL_FMT_D24S8) { pRT = CRenderTargetDX9::CreateDepthStencilRenderTarget( this, m_Allocator, width, height); } else { pRT = CRenderTargetDX9::CreateRenderTarget( this, m_Allocator, width, height, fmt); } if (pRT != IZ_NULL) { // リセット用リストに登録 m_ResetRT = InsertResource(pRT, m_ResetRT); } return pRT; }
/** * インデックスバッファ作成 */ CIndexBuffer* CGraphicsDeviceDX9::CreateIndexBuffer( IZ_UINT nIdxNum, E_GRAPH_INDEX_BUFFER_FMT fmt, E_GRAPH_RSC_USAGE usage) { CIndexBufferDX9* pIB = CIndexBufferDX9::CreateIndexBuffer( this, m_Allocator, nIdxNum, fmt, usage); if ((pIB != IZ_NULL) && pIB->IsDynamic()) { // リセット用リストに登録 m_ResetIB = InsertResource(pIB, m_ResetIB); } return pIB; }
/** * 頂点バッファ作成 */ CVertexBuffer* CGraphicsDeviceDX9::CreateVertexBuffer( IZ_UINT stride, IZ_UINT vtxNum, E_GRAPH_RSC_USAGE usage) { CVertexBufferDX9* pVB = CVertexBufferDX9::CreateVertexBuffer( this, m_Allocator, stride, vtxNum, usage); if ((pVB != IZ_NULL) && pVB->IsDynamic()) { // リセット用リストに登録 m_ResetVB = InsertResource(pVB, m_ResetVB); } return pVB; }
/** * テクスチャ作成 */ CTexture* CGraphicsDeviceDX9::CreateTexture( IZ_UINT width, IZ_UINT height, IZ_UINT mipLevel, E_GRAPH_PIXEL_FMT fmt, E_GRAPH_RSC_USAGE rscType) { CTextureDX9* pTexture = CTextureDX9::CreateTexture( this, m_Allocator, width, height, mipLevel, fmt, rscType); if ((pTexture != IZ_NULL) && pTexture->IsOnVram()) { // リセット用リストに登録 m_ResetTexture = InsertResource(pTexture, m_ResetTexture); } return pTexture; }
DXResourceHandle CDXShaderManager::CreateResource(void* pShaderDesc, WCHAR* szCustomKey) { DXResourceKey key; DXResourceMapInsertResult insertResult; DXResourceHandle returnValue; DXShaderDesc* pDesc; CDXShader* pShader; pDesc = (DXShaderDesc*)pShaderDesc; pShader = nullptr; // Custom key given? Well and good. But it's better not to provide a // custom key for shaders. if (szCustomKey) { wcscpy_s(key.m_szName, DX_MAX_RESOURCE_KEY_NAME, szCustomKey); } else // No? Process a key name of format %FILE%_%ENTRY%_%PROFILE% { WCHAR szFileName[DX_MAX_FILE_NAME]; WCHAR* pFileName; WCHAR* pDot; // Find the last slash. pFileName = wcsrchr(pDesc->szFileName, '\\'); // If not found, then only the file name is present. if (!pFileName) { pFileName = pDesc->szFileName; } // Copy the file name to a local variable. wcscpy_s(szFileName, DX_MAX_FILE_NAME, pFileName); // Find the extension full stop. pDot = wcsrchr(szFileName, '.'); // We don't need the file extension. if (pDot) { *pDot = 0; } // Format our key name: %FILE%_%ENTRY%_%PROFILE% // So keep file and function names small. wsprintf(key.m_szName, L"%s_%s_%s", szFileName, pDesc->szEntryPoint, pDesc->szShaderLevel); } // Try to insert the shader with the key into the map. insertResult = InsertResource(key, pShader); if (insertResult.second) // New resource inserted? { HRESULT hr = S_OK; // New shader resource on the heap. pShader = new CDXShader(); // Create the resource. NOTE: This does not create the resource // in the graphics memory. It only prepares the resource so that it // can be created anytime using Recreate() method. DX_V(pShader->Create(pShaderDesc)); if (FAILED(hr)) // Failed? { DX_DEBUG_OUTPUT2(L"Failed on a shader: FILE:%s, ENTRY: %s.", pDesc->szFileName, pDesc->szEntryPoint); // Free the memory. DX_SAFE_DELETE(pShader); return returnValue; } // Success! insertResult.first->second = pShader; AddMemoryUsage(pShader->GetSize()); } else // Existing element returned. { pShader = (CDXShader*)insertResult.first->second; } pShader->AddRef(); returnValue.key = key; returnValue.pResource = pShader; return returnValue; }