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

Function QueryPrimitiveIdPerFragment

renderdoc/driver/gl/gl_pixelhistory.cpp:2513–2669  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2511}
2512
2513void QueryPrimitiveIdPerFragment(WrappedOpenGL *driver, GLReplay *replay,
2514 GLPixelHistoryResources &resources,
2515 const rdcarray<EventUsage> &modEvents, int x, int y,
2516 rdcarray<PixelModification> &history,
2517 const std::map<uint32_t, uint32_t> &eventFragments,
2518 bool usingFloatForPrimitiveId, uint32_t numSamples,
2519 uint32_t sampleIndex)
2520{
2521 GLMarkerRegion region("QueryPrimitiveIdPerFragment");
2522 driver->ReplayLog(0, modEvents[0].eventId, eReplay_WithoutDraw);
2523
2524 for(size_t i = 0; i < modEvents.size(); i++)
2525 {
2526 auto it = eventFragments.find(modEvents[i].eventId);
2527 uint32_t numFragments = (it != eventFragments.end()) ? it->second : 0;
2528
2529 if(numFragments == 0)
2530 {
2531 if(i < modEvents.size() - 1)
2532 {
2533 driver->ReplayLog(modEvents[i].eventId, modEvents[i + 1].eventId, eReplay_WithoutDraw);
2534 }
2535 continue;
2536 }
2537
2538 GLRenderState state;
2539 state.FetchState(driver);
2540
2541 ResourceId ps;
2542 if(state.Program.name)
2543 ps = driver->GetProgram(driver->GetResourceManager()->GetResID(state.Program))
2544 .stageShaders[(int)ShaderStage::Pixel];
2545 else
2546 ps = driver->GetPipeline(driver->GetResourceManager()->GetResID(state.Pipeline))
2547 .stageShaders[(int)ShaderStage::Pixel];
2548
2549 driver->glBindFramebuffer(eGL_FRAMEBUFFER, resources.fullPrecisionFrameBuffer);
2550 driver->glReadBuffer(eGL_COLOR_ATTACHMENT0);
2551 // rebind colour image to 0
2552 for(uint32_t a = 1; a < 8; a++)
2553 driver->glFramebufferTexture(eGL_FRAMEBUFFER, GLenum(eGL_COLOR_ATTACHMENT0 + a), 0, 0);
2554 driver->glFramebufferTexture(eGL_FRAMEBUFFER, eGL_COLOR_ATTACHMENT0,
2555 resources.fullPrecisionColorImage, 0);
2556 driver->glDrawBuffer(eGL_COLOR_ATTACHMENT0);
2557
2558 driver->glEnable(eGL_SCISSOR_TEST);
2559 driver->glScissor(x, y, 1, 1);
2560
2561 driver->glClearStencil(0);
2562 driver->glEnable(eGL_DEPTH_TEST);
2563 if(HasExt[EXT_depth_bounds_test])
2564 driver->glDisable(eGL_DEPTH_BOUNDS_TEST_EXT);
2565 driver->glDepthFunc(eGL_ALWAYS);
2566 driver->glDepthMask(GL_TRUE);
2567 driver->glDisable(eGL_BLEND);
2568 driver->glDisable(eGL_SAMPLE_MASK);
2569 driver->glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
2570

Callers 1

PixelHistoryMethod · 0.85

Calls 15

GetPrimitiveIdProgramFunction · 0.85
SafeBlitFramebufferFunction · 0.85
getFramebufferCopyMaskFunction · 0.85
CopyMSSampleFunction · 0.85
FetchStateMethod · 0.80
GetResIDMethod · 0.80
ResourceIdFunction · 0.50
ReplayLogMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45
GetResourceManagerMethod · 0.45

Tested by

no test coverage detected