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

Method ReadTexel

renderdoc/driver/gl/gl_shaderdebug.cpp:301–443  ·  view source on GitHub ↗

Called from any thread Caller guarantees that if the image data is not cached then we are on the device thread

Source from the content-addressed store, hash-verified

299 // Called from any thread
300 // Caller guarantees that if the image data is not cached then we are on the device thread
301 virtual rdcspv::DeviceOpResult ReadTexel(const ShaderBindIndex &imageBind,
302 const ShaderVariable &coord, uint32_t sample,
303 ShaderVariable &output) override
304 {
305 rdcspv::DeviceOpResult opResult;
306 bool isCached = false;
307 {
308 SCOPED_READLOCK(imageCacheLock);
309 isCached = GetImageDataFromCache(imageBind, opResult) != NULL;
310 RDCASSERTNOTEQUAL(opResult, rdcspv::DeviceOpResult::NeedsDevice);
311 }
312
313 if(!isCached)
314 {
315 // Add image data to the cache : cache should not be locked by this thread
316 PopulateImage(imageBind);
317 }
318
319 {
320 SCOPED_READLOCK(imageCacheLock);
321 ImageData *result = GetImageDataFromCache(imageBind, opResult);
322 if(!result)
323 {
324 RDCASSERTEQUAL(opResult, rdcspv::DeviceOpResult::Failed);
325 return rdcspv::DeviceOpResult::Failed;
326 }
327
328 ImageData &data = *result;
329 if(data.width == 0)
330 return rdcspv::DeviceOpResult::Failed;
331
332 uint32_t coords[4];
333 for(int i = 0; i < 4; i++)
334 coords[i] = uintComp(coord, i);
335
336 if(coords[0] >= data.width || coords[1] >= data.height || coords[2] >= data.depth)
337 {
338 if(!IsDeviceThread())
339 return rdcspv::DeviceOpResult::NeedsDevice;
340
341 CHECK_DEVICE_THREAD();
342 m_pDriver->AddDebugMessage(
343 MessageCategory::Execution, MessageSeverity::High, MessageSource::RuntimeWarning,
344 StringFormat::Fmt(
345 "Out of bounds access to image, coord %u,%u,%u outside of dimensions %ux%ux%u",
346 coords[0], coords[1], coords[2], data.width, data.height, data.depth));
347 return rdcspv::DeviceOpResult::Failed;
348 }
349
350 CompType varComp = VarTypeCompType(output.type);
351
352 set0001(output);
353
354 ShaderVariable input;
355 input.columns = data.fmt.compCount;
356
357 // the only 'irregular' format we need to worry about handling for integer types is
358 // 10:10:10:2. All others are float/uint

Callers

nothing calls this directly

Calls 15

uintCompFunction · 0.85
FmtFunction · 0.85
VarTypeCompTypeFunction · 0.85
set0001Function · 0.85
RDCMINFunction · 0.85
setUintCompFunction · 0.85
setIntCompFunction · 0.85
intCompFunction · 0.85
setFloatCompFunction · 0.85
DecodePixelDataFunction · 0.50
memcpyFunction · 0.50

Tested by

no test coverage detected