MCPcopy Create free account
hub / github.com/baldurk/renderdoc / PatchFormatString

Function PatchFormatString

renderdoc/driver/vulkan/vk_shader_feedback.cpp:167–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165};
166
167rdcstr PatchFormatString(rdcstr format)
168{
169 // we don't support things like %XX.YYv2f so look for vector formatters and expand them to
170 // %XX.YYf, %XX.YYf
171 // Also annoyingly the printf specification for 64-bit integers is printed as %ul instead of %llu,
172 // so we need to patch that up too
173
174 for(size_t i = 0; i < format.size(); i++)
175 {
176 if(format[i] == '%')
177 {
178 size_t start = i;
179
180 i++;
181 if(format[i] == '%')
182 continue;
183
184 // skip to first letter
185 while(i < format.size() && !isalpha(format[i]))
186 i++;
187
188 // malformed string, abort
189 if(!isalpha(format[i]))
190 {
191 RDCERR("Malformed format string '%s'", format.c_str());
192 break;
193 }
194
195 // if the first letter is v, this is a vector format
196 if(format[i] == 'v' || format[i] == 'V')
197 {
198 size_t vecStart = i;
199
200 int vecsize = int(format[i + 1]) - int('0');
201
202 if(vecsize < 2 || vecsize > 4)
203 {
204 RDCERR("Malformed format string '%s'", format.c_str());
205 break;
206 }
207
208 // skip the v and the [234]
209 i += 2;
210
211 if(i >= format.size())
212 {
213 RDCERR("Malformed format string '%s'", format.c_str());
214 break;
215 }
216
217 bool int64 = false;
218 // if the final letter is u, we need to peek ahead to see if there's a l following
219 if(format[i] == 'u' && i + 1 < format.size() && format[i + 1] == 'l')
220 {
221 i++;
222 int64 = true;
223 }
224

Callers 2

AnnotateShaderFunction · 0.85

Calls 6

sizeMethod · 0.45
c_strMethod · 0.45
substrMethod · 0.45
eraseMethod · 0.45
pop_backMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected