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

Method ReadTexel

renderdoc/driver/vulkan/vk_shaderdebug.cpp:380–522  ·  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

378 // Called from any thread
379 // Caller guarantees that if the image data is not cached then we are on the device thread
380 virtual rdcspv::DeviceOpResult ReadTexel(const ShaderBindIndex &imageBind,
381 const ShaderVariable &coord, uint32_t sample,
382 ShaderVariable &output) override
383 {
384 rdcspv::DeviceOpResult opResult;
385 bool isCached = false;
386 {
387 SCOPED_READLOCK(imageCacheLock);
388 isCached = GetImageDataFromCache(imageBind, opResult) != NULL;
389 RDCASSERTNOTEQUAL(opResult, rdcspv::DeviceOpResult::NeedsDevice);
390 }
391
392 if(!isCached)
393 {
394 // Add image data to the cache : cache should not be locked by this thread
395 PopulateImage(imageBind);
396 }
397
398 {
399 SCOPED_READLOCK(imageCacheLock);
400 ImageData *result = GetImageDataFromCache(imageBind, opResult);
401 if(!result)
402 {
403 RDCASSERTEQUAL(opResult, rdcspv::DeviceOpResult::Failed);
404 return rdcspv::DeviceOpResult::Failed;
405 }
406
407 ImageData &data = *result;
408 if(data.width == 0)
409 return rdcspv::DeviceOpResult::Failed;
410
411 uint32_t coords[4];
412 for(int i = 0; i < 4; i++)
413 coords[i] = uintComp(coord, i);
414
415 if(coords[0] >= data.width || coords[1] >= data.height || coords[2] >= data.depth)
416 {
417 if(!IsDeviceThread())
418 return rdcspv::DeviceOpResult::NeedsDevice;
419
420 CHECK_DEVICE_THREAD();
421 m_pDriver->AddDebugMessage(
422 MessageCategory::Execution, MessageSeverity::High, MessageSource::RuntimeWarning,
423 StringFormat::Fmt(
424 "Out of bounds access to image, coord %u,%u,%u outside of dimensions %ux%ux%u",
425 coords[0], coords[1], coords[2], data.width, data.height, data.depth));
426 return rdcspv::DeviceOpResult::Failed;
427 }
428
429 CompType varComp = VarTypeCompType(output.type);
430
431 set0001(output);
432
433 ShaderVariable input;
434 input.columns = data.fmt.compCount;
435
436 // the only 'irregular' format we need to worry about handling for integer types is
437 // 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