HRESULT WINAPI D3DProxyDeviceEgo::SetVertexShaderConstantF(UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount) { if(stereoView->initialized && Vector4fCount >= 4 && validRegister(StartRegister)) // && (fabs(pConstantData[12]) + fabs(pConstantData[13]) + fabs(pConstantData[14]) > 0.001f)) { currentMatrix = const_cast<float*>(pConstantData); D3DXMATRIX sourceMatrix(currentMatrix); sourceMatrix = sourceMatrix * matViewTranslation; currentMatrix = (float*)sourceMatrix; /* char buf[32]; LPCSTR psz = NULL; //wsprintf(buf, "vp w: %d", separation); sprintf_s(buf, "sep: %f", separation); psz = buf; OutputDebugString(psz); OutputDebugString("\n"); */ if(saveDebugFile) { char vcString[1024]; sprintf_s(vcString, "register: %d, count: %d\n" "%.4f\t%.4f\t%.4f\t%.4f\n" "%.4f\t%.4f\t%.4f\t%.4f\n" "%.4f\t%.4f\t%.4f\t%.4f\n" "%.4f\t%.4f\t%.4f\t%.4f\n\n", StartRegister, Vector4fCount, currentMatrix[0], currentMatrix[1], currentMatrix[2], currentMatrix[3], currentMatrix[4], currentMatrix[5], currentMatrix[6], currentMatrix[7], currentMatrix[8], currentMatrix[9], currentMatrix[10], currentMatrix[11], currentMatrix[12], currentMatrix[13], currentMatrix[14], currentMatrix[15] ); debugFile << vcString; } return D3DProxyDevice::SetVertexShaderConstantF(StartRegister, currentMatrix, Vector4fCount); } return D3DProxyDevice::SetVertexShaderConstantF(StartRegister, pConstantData, Vector4fCount); }
void seissol::initializers::initializeCellLocalMatrices( MeshReader const& i_meshReader, unsigned* i_copyInteriorToMesh, unsigned* i_meshToLts, unsigned i_numberOfCopyInteriorCells, CellLocalInformation* i_cellInformation, CellData* io_cellData ) { std::vector<Element> const& elements = i_meshReader.getElements(); std::vector<Vertex> const& vertices = i_meshReader.getVertices(); real AT[STAR_NNZ]; real BT[STAR_NNZ]; real CT[STAR_NNZ]; real FlocalData[NUMBER_OF_QUANTITIES * NUMBER_OF_QUANTITIES]; real FneighborData[NUMBER_OF_QUANTITIES * NUMBER_OF_QUANTITIES]; real TData[NUMBER_OF_QUANTITIES * NUMBER_OF_QUANTITIES]; real TinvData[NUMBER_OF_QUANTITIES * NUMBER_OF_QUANTITIES]; #ifdef _OPENMP #pragma omp parallel for private(AT, BT, CT, FlocalData, FneighborData, TData, TinvData) schedule(static) #endif for (unsigned cell = 0; cell < i_numberOfCopyInteriorCells; ++cell) { unsigned meshId = i_copyInteriorToMesh[cell]; // The following is actually stupid. However, due to a lacking // concept it must do for now. \todo change. unsigned ltsCell = i_meshToLts[meshId]; real x[4]; real y[4]; real z[4]; real gradXi[3]; real gradEta[3]; real gradZeta[3]; // Iterate over all 4 vertices of the tetrahedron for (unsigned vertex = 0; vertex < 4; ++vertex) { VrtxCoords const& coords = vertices[ elements[meshId].vertices[vertex] ].coords; x[vertex] = coords[0]; y[vertex] = coords[1]; z[vertex] = coords[2]; } seissol::transformations::tetrahedronGlobalToReferenceJacobian( x, y, z, gradXi, gradEta, gradZeta ); seissol::model::getTransposedCoefficientMatrix( io_cellData->material[cell].local, 0, AT ); seissol::model::getTransposedCoefficientMatrix( io_cellData->material[cell].local, 1, BT ); seissol::model::getTransposedCoefficientMatrix( io_cellData->material[cell].local, 2, CT ); setStarMatrix(AT, BT, CT, gradXi, io_cellData->localIntegration[cell].starMatrices[0]); setStarMatrix(AT, BT, CT, gradEta, io_cellData->localIntegration[cell].starMatrices[1]); setStarMatrix(AT, BT, CT, gradZeta, io_cellData->localIntegration[cell].starMatrices[2]); double volume = MeshTools::volume(elements[meshId], vertices); for (unsigned side = 0; side < 4; ++side) { MatrixView<NUMBER_OF_QUANTITIES, NUMBER_OF_QUANTITIES> Flocal(FlocalData); MatrixView<NUMBER_OF_QUANTITIES, NUMBER_OF_QUANTITIES> Fneighbor(FneighborData); MatrixView<NUMBER_OF_QUANTITIES, NUMBER_OF_QUANTITIES> T(TData); MatrixView<NUMBER_OF_QUANTITIES, NUMBER_OF_QUANTITIES> Tinv(TinvData); seissol::model::getTransposedRiemannSolver( io_cellData->material[cell].local, io_cellData->material[cell].neighbor[side], i_cellInformation[ltsCell].faceTypes[side], //AT, Flocal, Fneighbor ); VrtxCoords normal; VrtxCoords tangent1; VrtxCoords tangent2; MeshTools::normalAndTangents(elements[meshId], side, vertices, normal, tangent1, tangent2); double surface = MeshTools::surface(normal); MeshTools::normalize(normal, normal); MeshTools::normalize(tangent1, tangent1); MeshTools::normalize(tangent2, tangent2); // Calculate transposed T instead seissol::model::getFaceRotationMatrix(normal, tangent1, tangent2, T, Tinv); MatrixView<NUMBER_OF_QUANTITIES, NUMBER_OF_QUANTITIES> nApNm1(io_cellData->localIntegration[cell].nApNm1[side]); MatrixView<NUMBER_OF_QUANTITIES, NUMBER_OF_QUANTITIES> nAmNm1(io_cellData->neighboringIntegration[cell].nAmNm1[side]); nApNm1.setZero(); nAmNm1.setZero(); // Scale with |S_side|/|J| and multiply with -1 as the flux matrices // must be subtracted. real fluxScale = -2.0 * surface / (6.0 * volume); // \todo Generate a kernel for this // Calculates Tinv^T * F * T^T for (unsigned j = 0; j < NUMBER_OF_QUANTITIES; ++j) { for (unsigned i = 0; i < NUMBER_OF_QUANTITIES; ++i) { for (unsigned k = 0; k < NUMBER_OF_QUANTITIES; ++k) { for (unsigned l = 0; l < NUMBER_OF_QUANTITIES; ++l) { nApNm1(i, j) += Tinv(k, i) * Flocal(k, l) * T(j, l); nAmNm1(i, j) += Tinv(k, i) * Fneighbor(k, l) * T(j, l); } } nApNm1(i, j) *= fluxScale; nAmNm1(i, j) *= fluxScale; } } } #ifdef REQUIRE_SOURCE_MATRIX MatrixView<NUMBER_OF_QUANTITIES, NUMBER_OF_QUANTITIES> sourceMatrix(io_cellData->localIntegration[cell].sourceMatrix); seissol::model::setSourceMatrix(io_cellData->material[cell].local, sourceMatrix); #endif } }
HRESULT WINAPI D3DProxyDeviceTest::SetVertexShaderConstantF(UINT StartRegister,CONST float* pConstantData,UINT Vector4fCount) { if(stereoView->initialized && validVectorCount(Vector4fCount) && validRegister(StartRegister)) { currentMatrix = const_cast<float*>(pConstantData); D3DXMATRIX sourceMatrix(currentMatrix); D3DXMatrixTranspose(&sourceMatrix, &sourceMatrix); //D3DXMatrixInverse(&sourceMatrix, 0, &sourceMatrix); D3DXMATRIX worldViewMatrix; D3DXMATRIX transMatrix; D3DXMatrixIdentity(&transMatrix); D3DXMATRIX worldViewTransMatrix; //D3DXMatrixTranslation(&transMatrix, separation*eyeShutter*50.0f, 0, 0); D3DXMatrixMultiply(&worldViewMatrix, &sourceMatrix, &matProjectionInv); D3DXMatrixMultiply(&worldViewTransMatrix, &worldViewMatrix, &transMatrix); /* D3DXMATRIX transMatrix; D3DXMatrixIdentity(&transMatrix); D3DXMatrixTranslation(&transMatrix, separation*eyeShutter*100.0f, 0, 0); D3DXMatrixMultiply(&sourceMatrix, &transMatrix, &sourceMatrix); */ //sourceMatrix[matrixIndex] += separation*eyeShutter*500.0f; worldViewTransMatrix[matrixIndex] += separation*eyeShutter*5.0f; D3DXMatrixMultiply(&sourceMatrix, &worldViewTransMatrix, &matProjection); //D3DXMatrixInverse(&sourceMatrix, 0, &sourceMatrix); D3DXMatrixTranspose(&sourceMatrix, &sourceMatrix); /* D3DXMATRIX sourceMatrix(currentMatrix); D3DXMatrixTranspose(&sourceMatrix, &sourceMatrix); D3DXMATRIX worldViewMatrix; D3DXMATRIX transMatrix; D3DXMatrixIdentity(&transMatrix); D3DXMATRIX worldViewTransMatrix; D3DXMatrixTranslation(&transMatrix, separation*eyeShutter*10.0f, 0, 0); //D3DXMatrixMultiply(&sourceMatrix, &sourceMatrix, &transMatrix); //D3DXMatrixMultiply(&worldViewMatrix, &sourceMatrix, &matProjectionInv); //transMatrix[8] += convergence*drawLeftEye; //D3DXMatrixMultiply(&worldViewTransMatrix, &worldViewMatrix, &transMatrix); //D3DXMATRIX rollMatrix; //D3DXMatrixRotationZ(&rollMatrix, currentRoll); //D3DXMatrixMultiply(&worldViewTransMatrix, &worldViewTransMatrix, &rollMatrix); //D3DXMatrixMultiply(&sourceMatrix, &worldViewTransMatrix, &matProjection); D3DXMatrixTranspose(&sourceMatrix, &sourceMatrix); // //sourceMatrix[0] += separation*eyeShutter; currentMatrix = (float*)sourceMatrix; currentMatrix[matrixIndex] += separation*eyeShutter; */ if(saveDebugFile) { char vcString[1024]; sprintf_s(vcString, "register: %d, count: %d\n" "%.4f\t%.4f\t%.4f\t%.4f\n" "%.4f\t%.4f\t%.4f\t%.4f\n" "%.4f\t%.4f\t%.4f\t%.4f\n" "%.4f\t%.4f\t%.4f\t%.4f\n\n", StartRegister, Vector4fCount, currentMatrix[0], currentMatrix[1], currentMatrix[2], currentMatrix[3], currentMatrix[4], currentMatrix[5], currentMatrix[6], currentMatrix[7], currentMatrix[8], currentMatrix[9], currentMatrix[10], currentMatrix[11], currentMatrix[12], currentMatrix[13], currentMatrix[14], currentMatrix[15] ); debugFile << vcString; } //sourceMatrix._13 += separation*eyeShutter; //currentMatrix = (float*)sourceMatrix; currentMatrix[0] = sourceMatrix._11; currentMatrix[1] = sourceMatrix._12; currentMatrix[2] = sourceMatrix._13; currentMatrix[3] = sourceMatrix._14; currentMatrix[4] = sourceMatrix._21; currentMatrix[5] = sourceMatrix._22; currentMatrix[6] = sourceMatrix._23; currentMatrix[7] = sourceMatrix._24; currentMatrix[8] = sourceMatrix._31; currentMatrix[9] = sourceMatrix._32; currentMatrix[10] = sourceMatrix._33; currentMatrix[11] = sourceMatrix._34; currentMatrix[12] = sourceMatrix._41; currentMatrix[13] = sourceMatrix._42; currentMatrix[14] = sourceMatrix._43; currentMatrix[15] = sourceMatrix._44; //currentMatrix[matrixIndex] += separation*eyeShutter*5.0f; //currentMatrix[matrixIndex] += separation*eyeShutter*50.0f; return D3DProxyDevice::SetVertexShaderConstantF(StartRegister, currentMatrix, Vector4fCount); } return D3DProxyDevice::SetVertexShaderConstantF(StartRegister, pConstantData, Vector4fCount); }
void seissol::model::initializeSpecificLocalData( seissol::model::Material const& material, seissol::model::LocalData* localData ) { MatrixView sourceMatrix(localData->sourceMatrix, seissol::model::source::reals, seissol::model::source::index); sourceMatrix.setZero(); // | E_1^T | // E^T = | ... | // | E_L^T | for (unsigned mech = 0; mech < NUMBER_OF_RELAXATION_MECHANISMS; ++mech) { unsigned offset = 9 + mech * 6; real const* theta = material.theta[mech]; sourceMatrix(offset, 0) = theta[0]; sourceMatrix(offset + 1, 0) = theta[1]; sourceMatrix(offset + 2, 0) = theta[1]; sourceMatrix(offset, 1) = theta[1]; sourceMatrix(offset + 1, 1) = theta[0]; sourceMatrix(offset + 2, 1) = theta[1]; sourceMatrix(offset, 2) = theta[1]; sourceMatrix(offset + 1, 2) = theta[1]; sourceMatrix(offset + 2, 2) = theta[0]; sourceMatrix(offset + 3, 3) = theta[2]; sourceMatrix(offset + 4, 4) = theta[2]; sourceMatrix(offset + 5, 5) = theta[2]; } // E' = diag(-omega_1 I, ..., -omega_L I) for (unsigned mech = 0; mech < NUMBER_OF_RELAXATION_MECHANISMS; ++mech) { for (unsigned i = 0; i < 6; ++i) { unsigned idx = 9 + 6*mech + i; sourceMatrix(idx, idx) = -material.omega[mech]; } } }