void Shader::onResourceLoaded( ResourcesManager& resMgr ) { Resource::onResourceLoaded( resMgr ); if ( m_scriptPath.empty() ) { // assign an initial path getFilePath().changeFileExtension( "code", m_scriptPath ); } parseConstants(); }
BOOL R_constant_table::parse (void* _desc, u16 destination) { ID3D10ShaderReflection *pReflection = (ID3D10ShaderReflection *)_desc; D3D10_SHADER_DESC ShaderDesc; pReflection->GetDesc(&ShaderDesc); if (ShaderDesc.ConstantBuffers) { m_CBTable.reserve(ShaderDesc.ConstantBuffers); // Parse single constant table ID3D10ShaderReflectionConstantBuffer *pTable=0; for (u16 iBuf = 0; iBuf<ShaderDesc.ConstantBuffers; ++iBuf) { pTable = pReflection->GetConstantBufferByIndex(iBuf); if (pTable) { // Encode buffer index into destination u16 updatedDest = destination; updatedDest |= iBuf << ((destination&RC_dest_pixel) ? RC_dest_pixel_cb_index_shift : (destination&RC_dest_vertex) ? RC_dest_vertex_cb_index_shift : RC_dest_geometry_cb_index_shift); // Encode bind dest (pixel/vertex buffer) and bind point index u32 uiBufferIndex = iBuf; uiBufferIndex |= (destination&RC_dest_pixel) ? CB_BufferPixelShader : (destination&RC_dest_vertex) ? CB_BufferVertexShader : CB_BufferGeometryShader; parseConstants(pTable,updatedDest); ref_cbuffer tempBuffer = dxRenderDeviceRender::Instance().Resources->_CreateConstantBuffer(pTable); m_CBTable.push_back(cb_table_record(uiBufferIndex, tempBuffer)); } } } if (ShaderDesc.BoundResources) { parseResources(pReflection, ShaderDesc.BoundResources, destination); } std::sort (table.begin(),table.end(),p_sort); return TRUE; }
void Shader::build() { parseConstants(); m_renderResource->setDirty(); }