https://bugs.webkit.org/show_bug.cgi?id=190452
<rdar://problem/
45178272>
Reviewed by Myles Maxfield.
Correctly label the appropriate semantics as [[position]]
and [[color(N)]].
* WebGPUShadingLanguageRI/Metal/MSLBackend.js: Identify position
and color attributes. Also use the semantic's index rather than
a counter.
* WebGPUShadingLanguageRI/Metal/WhlslToMsl.html: Use a <pre> for
output, and only include the actual shader code.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237022
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2018-10-10 Dean Jackson <dino@apple.com>
+
+ [WHSL -> MSL] Annotate semantics correctly in generated MSL
+ https://bugs.webkit.org/show_bug.cgi?id=190452
+ <rdar://problem/45178272>
+
+ Reviewed by Myles Maxfield.
+
+ Correctly label the appropriate semantics as [[position]]
+ and [[color(N)]].
+
+ * WebGPUShadingLanguageRI/Metal/MSLBackend.js: Identify position
+ and color attributes. Also use the semantic's index rather than
+ a counter.
+ * WebGPUShadingLanguageRI/Metal/WhlslToMsl.html: Use a <pre> for
+ output, and only include the actual shader code.
+
2018-10-10 Ross Kirsling <ross.kirsling@sony.com>
build-webkit --inspector-frontend shouldn't have a nonzero exit code
const structTypeAttributes = this._allTypeAttributes.attributesForType(structType);
let src = `struct ${this._typeUnifier.uniqueTypeId(structType)} {\n`;
- let index = 0;
for (let [fieldName, field] of structType.fieldMap) {
const mangledFieldName = structTypeAttributes.mangledFieldName(fieldName);
src += ` ${this._typeUnifier.uniqueTypeId(field.type)} ${mangledFieldName}`;
const annotations = [];
if (structTypeAttributes.isVertexAttribute)
- annotations.push(`attribute(${index++})`);
- if (structTypeAttributes.isVertexOutputOrFragmentInput && fieldName === "wsl_Position")
+ annotations.push(`attribute(${field._semantic._index})`);
+ if (structTypeAttributes.isVertexOutputOrFragmentInput && field._semantic._name === "SV_Position")
annotations.push("position");
- if (structTypeAttributes.isFragmentOutput && fieldName === "wsl_Color")
- annotations.push("color(0)");
+ if (structTypeAttributes.isFragmentOutput && field._semantic._name == "SV_Target")
+ annotations.push(`color(${field._semantic._extraArguments[0]})`);
if (annotations.length)
src += ` [[${annotations.join(", ")}]]`;
src += `; // ${fieldName} (${field.type}) \n`;
let output = document.querySelector("#output");
output.textContent = "Compiling...";
let result = whlslToMsl(source);
- output.textContent = JSON.stringify(result);
+ if (!result._error) {
+ output.textContent = result._metalShaderLanguageSource;
+ } else {
+ output.textContent = `Error: ${result._error.originString}\n${result._error.syntaxErrorMessage}`;
+ }
}
window.addEventListener("load", init, false);
return result;
}
</textarea>
-<div id="output">
+<pre id="output">
No compiled output.
-</div>
+</pre>
<div id="controls">
<button>Compile</button>
</div>