| 4099 | } |
| 4100 | |
| 4101 | void TextureViewer::on_debugPixelContext_clicked() |
| 4102 | { |
| 4103 | if(m_PickedPoint.x() < 0 || m_PickedPoint.y() < 0) |
| 4104 | return; |
| 4105 | |
| 4106 | TextureDescription *texptr = GetCurrentTexture(); |
| 4107 | |
| 4108 | int x = MipCoordFromBase(m_PickedPoint.x(), texptr->width); |
| 4109 | int y = MipCoordFromBase(m_PickedPoint.y(), texptr->height); |
| 4110 | |
| 4111 | uint32_t mipHeight = qMax(1U, texptr->height >> (int)m_TexDisplay.subresource.mip); |
| 4112 | |
| 4113 | if(m_TexDisplay.flipY) |
| 4114 | y = (int)(mipHeight - 1) - y; |
| 4115 | |
| 4116 | bool done = false; |
| 4117 | ShaderDebugTrace *trace = NULL; |
| 4118 | |
| 4119 | uint32_t view = m_TexDisplay.subresource.slice - m_Following.GetFirstArraySlice(m_Ctx); |
| 4120 | m_Ctx.Replay().AsyncInvoke([this, &trace, &done, x, y, view](IReplayController *r) { |
| 4121 | DebugPixelInputs inputs; |
| 4122 | inputs.sample = m_TexDisplay.subresource.sample; |
| 4123 | inputs.view = view; |
| 4124 | trace = r->DebugPixel((uint32_t)x, (uint32_t)y, inputs); |
| 4125 | |
| 4126 | if(trace->debugger == NULL) |
| 4127 | { |
| 4128 | r->FreeTrace(trace); |
| 4129 | trace = NULL; |
| 4130 | } |
| 4131 | |
| 4132 | done = true; |
| 4133 | }); |
| 4134 | |
| 4135 | QString debugContext = tr("Pixel %1,%2").arg(x).arg(y); |
| 4136 | |
| 4137 | // wait a short while before displaying the progress dialog (which won't show if we're already |
| 4138 | // done by the time we reach it) |
| 4139 | for(int i = 0; !done && i < 100; i++) |
| 4140 | QThread::msleep(5); |
| 4141 | |
| 4142 | ShowProgressDialog(this, tr("Debugging %1").arg(debugContext), [&done]() { return done; }); |
| 4143 | |
| 4144 | // if we couldn't debug the pixel on this event, open up a pixel history |
| 4145 | if(!trace) |
| 4146 | { |
| 4147 | if(m_Ctx.APIProps().pixelHistory) |
| 4148 | ShowPixelHistory(true); |
| 4149 | else |
| 4150 | RDDialog::critical(this, tr("Debug Error"), tr("Error debugging pixel.")); |
| 4151 | return; |
| 4152 | } |
| 4153 | |
| 4154 | const ShaderReflection *shaderDetails = |
| 4155 | m_Ctx.CurPipelineState().GetShaderReflection(ShaderStage::Pixel); |
| 4156 | ResourceId pipeline = m_Ctx.CurPipelineState().GetGraphicsPipelineObject(); |
| 4157 | |
| 4158 | // viewer takes ownership of the trace |
nothing calls this directly
no test coverage detected