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

Method PickPixel

renderdoc/driver/gl/gl_debug.cpp:1825–1925  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1823}
1824
1825void GLReplay::PickPixel(ResourceId texture, uint32_t x, uint32_t y, const Subresource &sub,
1826 CompType typeCast, float pixel[4])
1827{
1828 WrappedOpenGL &drv = *m_pDriver;
1829
1830 MakeCurrentReplayContext(m_DebugCtx);
1831
1832 drv.glBindFramebuffer(eGL_FRAMEBUFFER, DebugData.pickPixelFBO);
1833 drv.glBindFramebuffer(eGL_READ_FRAMEBUFFER, DebugData.pickPixelFBO);
1834
1835 pixel[0] = pixel[1] = pixel[2] = pixel[3] = 0.0f;
1836 drv.glClearBufferfv(eGL_COLOR, 0, pixel);
1837
1838 DebugData.outWidth = DebugData.outHeight = 1.0f;
1839 drv.glViewport(0, 0, 1, 1);
1840
1841 TextureDisplay texDisplay;
1842
1843 texDisplay.red = texDisplay.green = texDisplay.blue = texDisplay.alpha = true;
1844 texDisplay.flipY = false;
1845 texDisplay.hdrMultiplier = -1.0f;
1846 texDisplay.linearDisplayAsGamma = true;
1847 texDisplay.subresource = sub;
1848 texDisplay.customShaderId = ResourceId();
1849 texDisplay.rangeMin = 0.0f;
1850 texDisplay.rangeMax = 1.0f;
1851 texDisplay.scale = 1.0f;
1852 texDisplay.resourceId = texture;
1853 texDisplay.typeCast = typeCast;
1854 texDisplay.rawOutput = true;
1855 texDisplay.xOffset = -float(x << sub.mip);
1856 texDisplay.yOffset = -float(y << sub.mip);
1857
1858 WrappedOpenGL::TextureData &texDetails = m_pDriver->m_Textures[texDisplay.resourceId];
1859
1860 uint32_t mipWidth = RDCMAX(1U, (uint32_t)texDetails.width >> sub.mip);
1861 uint32_t mipHeight = RDCMAX(1U, (uint32_t)texDetails.height >> sub.mip);
1862
1863 texDisplay.xOffset = -(float(x) / float(mipWidth)) * texDetails.width;
1864 texDisplay.yOffset = -(float(y) / float(mipHeight)) * texDetails.height;
1865
1866 RenderTextureInternal(texDisplay, eTexDisplay_MipShift);
1867
1868 drv.glReadPixels(0, 0, 1, 1, eGL_RGBA, eGL_FLOAT, (void *)pixel);
1869
1870 if(!HasExt[ARB_gpu_shader5])
1871 {
1872 if(IsSIntFormat(texDetails.internalFormat))
1873 {
1874 int32_t casted[4] = {
1875 (int32_t)pixel[0],
1876 (int32_t)pixel[1],
1877 (int32_t)pixel[2],
1878 (int32_t)pixel[3],
1879 };
1880
1881 memcpy(pixel, casted, sizeof(casted));
1882 }

Callers 15

RT_FetchCurrentPixelMethod · 0.45
check_pixel_valueMethod · 0.45
check_textureMethod · 0.45
check_captureMethod · 0.45
check_captureMethod · 0.45
pickMethod · 0.45
sampleMethod · 0.45
check_captureMethod · 0.45
check_captureMethod · 0.45
get_overlay_pixelMethod · 0.45

Calls 9

RDCMAXFunction · 0.85
IsSIntFormatFunction · 0.70
IsUIntFormatFunction · 0.70
ResourceIdFunction · 0.50
memcpyFunction · 0.50
glBindFramebufferMethod · 0.45
glClearBufferfvMethod · 0.45
glViewportMethod · 0.45
glReadPixelsMethod · 0.45

Tested by 2

check_pixel_valueMethod · 0.36
check_captureMethod · 0.36