1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
bool SceneRenderer::setPerMaterialData(const CurrentWorkingData& currentData, const Material* pMaterial) { ConstantBuffer* pCB = currentData.pVars->getConstantBuffer(kPerMaterialCbName).get(); if (pCB) { pMaterial->setIntoProgramVars(currentData.pVars, pCB, "gMaterial"); } return true; } void SceneRenderer::updateVariableOffsets(const ProgramReflection* pReflector) { if (sWorldMatOffset == ConstantBuffer::kInvalidOffset) { const auto pPerMeshCbData = pReflector->getBufferDesc(kPerMeshCbName, ProgramReflection::BufferReflection::Type::Constant); if (pPerMeshCbData != nullptr) { assert(pPerMeshCbData->getVariableData("gWorldMat[0]")->isRowMajor == false); // We copy into CBs as column-major assert(pPerMeshCbData->getVariableData("gWorldInvTransposeMat[0]")->isRowMajor == false); assert(pPerMeshCbData->getVariableData("gWorldMat")->arraySize == pPerMeshCbData->getVariableData("gWorldInvTransposeMat")->arraySize); sWorldMatArraySize = pPerMeshCbData->getVariableData("gWorldMat")->arraySize; sWorldMatOffset = pPerMeshCbData->getVariableData("gWorldMat[0]")->location; sWorldInvTransposeMatOffset = pPerMeshCbData->getVariableData("gWorldInvTransposeMat[0]")->location; sMeshIdOffset = pPerMeshCbData->getVariableData("gMeshId")->location; sDrawIDOffset = pPerMeshCbData->getVariableData("gDrawId[0]")->location; } } if (sCameraDataOffset == ConstantBuffer::kInvalidOffset) { const auto pPerFrameCbData = pReflector->getBufferDesc(kPerFrameCbName, ProgramReflection::BufferReflection::Type::Constant); if (pPerFrameCbData != nullptr) { sCameraDataOffset = pPerFrameCbData->getVariableData("gCam.viewMat")->location; const auto& pCountOffset = pPerFrameCbData->getVariableData("gLightsCount"); sLightCountOffset = pCountOffset ? pCountOffset->location : ConstantBuffer::kInvalidOffset; const auto& pLightOffset = pPerFrameCbData->getVariableData("gLights[0].worldPos"); sLightArrayOffset = pLightOffset ? pLightOffset->location : ConstantBuffer::kInvalidOffset; const auto& pAmbientOffset = pPerFrameCbData->getVariableData("gAmbientLighting"); sAmbientLightOffset = pAmbientOffset ? pAmbientOffset->location : ConstantBuffer::kInvalidOffset; } } } |
D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT = 8