Skip to content

Commit

Permalink
Improve error display and make entry points visible
Browse files Browse the repository at this point in the history
  • Loading branch information
Devon7925 committed Jan 10, 2025
1 parent c76983d commit 8570f57
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
12 changes: 6 additions & 6 deletions compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,16 @@ export class SlangCompiler {
// dropdown list. Then, we will find whether user code also defines other entry points, if it has
// we will also add them to the dropdown list.
findDefinedEntryPoints(shaderSource: string): string[] {
var result: string[] = [];
let result: string[] = [];
if (shaderSource.match("imageMain")) {
return ["imageMain"];
result.push("imageMain");
}
if (shaderSource.match("printMain")) {
return ["printMain"];
result.push("printMain");
}

let slangSession: Session | null | undefined;
try {
var slangSession = this.globalSlangSession?.createSession(
slangSession = this.globalSlangSession?.createSession(
this.findCompileTarget("SPIRV"));
if (!slangSession) {
return [];
Expand Down Expand Up @@ -430,7 +430,7 @@ export class SlangCompiler {
loadModule(slangSession: Session, moduleName: string, source: string, componentTypeList: Module[]) {
var module: Module | null = slangSession.loadModuleFromSource(source, moduleName, "/" + moduleName + ".slang");
if (!module) {
var error = this.slangWasmModule.getLastError();
const error = this.slangWasmModule.getLastError();
console.error(error.type + " error: " + error.message);
this.diagnosticsMsg += (error.type + " error: " + error.message);
return false;
Expand Down
10 changes: 7 additions & 3 deletions try-slang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ export function setEditorValue(editor: monaco.editor.IStandaloneCodeEditor, valu
editor.revealLine(0);
}

export function appendEditorValue(editor: monaco.editor.IStandaloneCodeEditor, value: string, revealEnd: boolean = false) {
setEditorValue(editor, editor.getValue() + value, revealEnd);
}

async function webgpuInit() {
try {
const adapter = await navigator.gpu?.requestAdapter();
Expand Down Expand Up @@ -186,10 +190,10 @@ function withRenderLock(setupFn: { (): Promise<void>; }, renderFn: { (timeMS: nu
requestAnimationFrame(newRenderLoop);
}).catch((error: Error) => {
if (error instanceof NotReadyError) {
}
else {
// do nothing
} else {
if (diagnosticsArea != null)
setEditorValue(diagnosticsArea, error.message, true);
appendEditorValue(diagnosticsArea, error.message, true);
}
releaseRenderLock();
});
Expand Down

0 comments on commit 8570f57

Please sign in to comment.