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

Method RGLFile

Source/Falcor/Scene/Material/RGLFile.cpp:136–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134 }
135
136 RGLFile::RGLFile(std::ifstream& in)
137 {
138 auto readBytes = [&](void* dst, size_t size)
139 {
140 in.read(reinterpret_cast<char*>(dst), size);
141 };
142
143 uint8_t header[12];
144 readBytes(header, 12);
145
146 uint8_t version[2];
147 readBytes(version, 2);
148
149 uint32_t fieldCount;
150 readBytes(&fieldCount, 4);
151
152 if (strcmp(reinterpret_cast<const char*>(header), "tensor_file"))
153 {
154 FALCOR_THROW("Invalid file header");
155 }
156 if (version[0] != 1 || version[1] != 0)
157 {
158 FALCOR_THROW("Unsupported file version");
159 }
160
161 for (uint32_t i = 0; i < fieldCount; ++i)
162 {
163 uint16_t nameLength;
164 readBytes(&nameLength, 2);
165
166 std::string fieldName(nameLength, '\0');
167 readBytes(&fieldName[0], nameLength);
168
169 uint16_t fieldDim;
170 readBytes(&fieldDim, 2);
171
172 uint8_t fieldType;
173 readBytes(&fieldType, 1);
174
175 uint64_t offset;
176 readBytes(&offset, 8);
177
178 Field field;
179 field.name = fieldName;
180 field.type = FieldType(fieldType);
181 field.dim = fieldDim;
182 field.shape.reset(new uint64_t[fieldDim]);
183 readBytes(field.shape.get(), 8 * fieldDim);
184
185 if (!in.good()) FALCOR_THROW("Error parsing RGL field: File truncated");
186
187 size_t elemSize = fieldSize(FieldType(fieldType));
188 if (elemSize == 0)
189 {
190 // Unsupported field type - ignore, we don't need it.
191 continue;
192 }
193

Callers

nothing calls this directly

Calls 9

stringFunction · 0.85
tellgMethod · 0.80
seekgMethod · 0.80
FieldTypeEnum · 0.70
readMethod · 0.45
resetMethod · 0.45
getMethod · 0.45
insertMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected