MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / getMaterialParamsPython

Function getMaterialParamsPython

Source/Falcor/Scene/Scene.cpp:4193–4214  ·  view source on GitHub ↗

Get serialized material parameters for a list of materials. * \param materialIDsBuffer Buffer containing material IDs * \param paramsBuffer Buffer to write material parameters to */

Source from the content-addressed store, hash-verified

4191 * \param paramsBuffer Buffer to write material parameters to
4192 */
4193 inline void getMaterialParamsPython(Scene& scene, ref<Buffer> materialIDsBuffer, ref<Buffer> paramsBuffer)
4194 {
4195 // Get material IDs from buffer.
4196 FALCOR_CHECK(materialIDsBuffer->getStructSize() == sizeof(uint32_t), "Material IDs buffer must contain uint32_t elements.");
4197 std::vector<uint32_t> materialIDs = materialIDsBuffer->getElements<uint32_t>();
4198
4199 // Fetch material parameters.
4200 std::vector<float> params;
4201 params.reserve(materialIDs.size() * SerializedMaterialParams::kParamCount);
4202 for (uint32_t materialID : materialIDs)
4203 {
4204 SerializedMaterialParams tmpParams = scene.getMaterial(MaterialID(materialID))->serializeParams();
4205 params.insert(params.end(), tmpParams.begin(), tmpParams.end());
4206 }
4207
4208 // Write material parameters to buffer.
4209 FALCOR_CHECK(paramsBuffer->getSize() >= params.size() * sizeof(float), "Material parameter buffer is too small.");
4210 paramsBuffer->setBlob(params.data(), 0, params.size() * sizeof(float));
4211#if FALCOR_HAS_CUDA
4212 scene.getDevice()->getRenderContext()->waitForFalcor();
4213#endif
4214 }
4215
4216 /** Set serialized material parameters for a list of materials.
4217 * \param materialIDsBuffer Buffer containing material IDs

Callers

nothing calls this directly

Calls 12

getMaterialMethod · 0.80
reserveMethod · 0.45
sizeMethod · 0.45
serializeParamsMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
getSizeMethod · 0.45
setBlobMethod · 0.45
dataMethod · 0.45
waitForFalcorMethod · 0.45
getDeviceMethod · 0.45

Tested by

no test coverage detected