Skip to content

Commit

Permalink
Invert gpuMark, add reasons why it cannot be rendered to title
Browse files Browse the repository at this point in the history
Fixes #233993
  • Loading branch information
Tyriar committed Nov 16, 2024
1 parent 11ce150 commit e354996
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
24 changes: 24 additions & 0 deletions src/vs/editor/browser/gpu/viewGpuContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,28 @@ export class ViewGpuContext extends Disposable {
}
return true;
}

/**
* Like {@link canRender} but returned detailed information about why the line cannot be rendered.
*/
public static canRenderDetailed(options: ViewLineOptions, viewportData: ViewportData, lineNumber: number): string[] {
const data = viewportData.getViewLineRenderingData(lineNumber);
const reasons: string[] = [];
if (data.containsRTL) {
reasons.push('containsRTL');
}
if (data.maxColumn > GpuRenderLimits.maxGpuCols) {
reasons.push('maxColumn > maxGpuCols');
}
if (data.continuesWithWrappedLine) {
reasons.push('continuesWithWrappedLine');
}
if (data.inlineDecorations.length > 0) {
reasons.push('inlineDecorations > 0');
}
if (lineNumber >= GpuRenderLimits.maxGpuLines) {
reasons.push('lineNumber >= maxGpuLines');
}
return reasons;
}
}
10 changes: 8 additions & 2 deletions src/vs/editor/browser/viewParts/gpuMark/gpuMark.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
top: 0;
bottom: 0;
left: 0;
width: 2px;
width: 100%;
display: inline-block;
background: var(--vscode-editorLineNumber-foreground);
border-left: solid 2px var(--vscode-editorWarning-foreground);
opacity: 0.2;
transition: background-color 0.1s linear;
}

.monaco-editor .margin-view-overlays .gpu-mark:hover {
background-color: var(--vscode-editorWarning-foreground)
}
4 changes: 2 additions & 2 deletions src/vs/editor/browser/viewParts/gpuMark/gpuMark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ export class GpuMarkOverlay extends DynamicViewOverlay {
const output: string[] = [];
for (let lineNumber = visibleStartLineNumber; lineNumber <= visibleEndLineNumber; lineNumber++) {
const lineIndex = lineNumber - visibleStartLineNumber;
const canRender = ViewGpuContext.canRender(options, viewportData, lineNumber);
output[lineIndex] = canRender ? `<div class="${GpuMarkOverlay.CLASS_NAME}"></div>` : '';
const cannotRenderReasons = ViewGpuContext.canRenderDetailed(options, viewportData, lineNumber);
output[lineIndex] = cannotRenderReasons.length ? `<div class="${GpuMarkOverlay.CLASS_NAME}" title="Cannot render on GPU: ${cannotRenderReasons.join(', ')}"></div>` : '';
}

this._renderResult = output;
Expand Down

0 comments on commit e354996

Please sign in to comment.