Modified: trunk/Tools/WebGPUShadingLanguageRI/Intrinsics.js (236387 => 236388)
--- trunk/Tools/WebGPUShadingLanguageRI/Intrinsics.js 2018-09-22 23:22:55 UTC (rev 236387)
+++ trunk/Tools/WebGPUShadingLanguageRI/Intrinsics.js 2018-09-22 23:34:50 UTC (rev 236388)
@@ -1177,8 +1177,10 @@
let mipID = miplevel.loadValue();
if (mipID >= tex.levelCount)
throw new WTrapError("[GetDimensions]", "Reading from nonexistant mip level of texture");
- width.loadValue().copyFrom(EPtr.box(tex.widthAtLevel(mipID)), 1);
- numberOfLevels.loadValue().copyFrom(EPtr.box(tex.levelCount), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.widthAtLevel(mipID)), 1);
+ if (numberOfLevels.loadValue())
+ numberOfLevels.loadValue().copyFrom(EPtr.box(tex.levelCount), 1);
}
});
@@ -1221,9 +1223,12 @@
let mipID = miplevel.loadValue();
if (mipID >= tex.levelCount)
throw new WTrapError("[GetDimensions]", "Reading from nonexistant mip level of texture");
- width.loadValue().copyFrom(EPtr.box(tex.widthAtLevel(mipID)), 1);
- elements.loadValue().copyFrom(EPtr.box(tex.layerCount), 1);
- numberOfLevels.loadValue().copyFrom(EPtr.box(tex.levelCount), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.widthAtLevel(mipID)), 1);
+ if (elements.loadValue())
+ elements.loadValue().copyFrom(EPtr.box(tex.layerCount), 1);
+ if (numberOfLevels.loadValue())
+ numberOfLevels.loadValue().copyFrom(EPtr.box(tex.levelCount), 1);
}
});
@@ -1412,9 +1417,12 @@
let mipID = miplevel.loadValue();
if (mipID >= tex.levelCount)
throw new WTrapError("[GetDimensions]", "Reading from nonexistant mip level of texture");
- height.loadValue().copyFrom(EPtr.box(tex.heightAtLevel(mipID)), 1);
- width.loadValue().copyFrom(EPtr.box(tex.widthAtLevel(mipID)), 1);
- numberOfLevels.loadValue().copyFrom(EPtr.box(tex.levelCount), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.widthAtLevel(mipID)), 1);
+ if (height.loadValue())
+ height.loadValue().copyFrom(EPtr.box(tex.heightAtLevel(mipID)), 1);
+ if (numberOfLevels.loadValue())
+ numberOfLevels.loadValue().copyFrom(EPtr.box(tex.levelCount), 1);
}
});
@@ -1603,10 +1611,14 @@
let mipID = miplevel.loadValue();
if (mipID >= tex.levelCount)
throw new WTrapError("[GetDimensions]", "Reading from nonexistant mip level of texture");
- height.loadValue().copyFrom(EPtr.box(tex.heightAtLevel(mipID)), 1);
- width.loadValue().copyFrom(EPtr.box(tex.widthAtLevel(mipID)), 1);
- elements.loadValue().copyFrom(EPtr.box(tex.layerCount), 1);
- numberOfLevels.loadValue().copyFrom(EPtr.box(tex.levelCount), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.widthAtLevel(mipID)), 1);
+ if (height.loadValue())
+ height.loadValue().copyFrom(EPtr.box(tex.heightAtLevel(mipID)), 1);
+ if (elements.loadValue())
+ elements.loadValue().copyFrom(EPtr.box(tex.layerCount), 1);
+ if (numberOfLevels.loadValue())
+ numberOfLevels.loadValue().copyFrom(EPtr.box(tex.levelCount), 1);
}
});
@@ -1649,10 +1661,14 @@
let mipID = miplevel.loadValue();
if (mipID >= tex.levelCount)
throw new WTrapError("[GetDimensions]", "Reading from nonexistant mip level of texture");
- depth.loadValue().copyFrom(EPtr.box(tex.depthAtLevel(mipID)), 1);
- height.loadValue().copyFrom(EPtr.box(tex.heightAtLevel(mipID)), 1);
- width.loadValue().copyFrom(EPtr.box(tex.widthAtLevel(mipID)), 1);
- numberOfLevels.loadValue().copyFrom(EPtr.box(tex.levelCount), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.widthAtLevel(mipID)), 1);
+ if (height.loadValue())
+ height.loadValue().copyFrom(EPtr.box(tex.heightAtLevel(mipID)), 1);
+ if (depth.loadValue())
+ depth.loadValue().copyFrom(EPtr.box(tex.depthAtLevel(mipID)), 1);
+ if (numberOfLevels.loadValue())
+ numberOfLevels.loadValue().copyFrom(EPtr.box(tex.levelCount), 1);
}
});
@@ -1746,9 +1762,12 @@
throw new Error("Cube texture doesn't have 6 faces");
if (mipID >= tex.levelCount)
throw new WTrapError("[GetDimensions]", "Reading from nonexistant mip level of texture");
- height.loadValue().copyFrom(EPtr.box(tex.heightAtLevel(mipID)), 1);
- width.loadValue().copyFrom(EPtr.box(tex.widthAtLevel(mipID)), 1);
- numberOfLevels.loadValue().copyFrom(EPtr.box(tex.levelCount), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.widthAtLevel(mipID)), 1);
+ if (height.loadValue())
+ height.loadValue().copyFrom(EPtr.box(tex.heightAtLevel(mipID)), 1);
+ if (numberOfLevels.loadValue())
+ numberOfLevels.loadValue().copyFrom(EPtr.box(tex.levelCount), 1);
}
});
@@ -1756,7 +1775,8 @@
`native void GetDimensions(RWTexture1D<${type}${length}>,uint* thread Width)`,
func => {
func.implementation = function([texture, width]) {
- width.loadValue().copyFrom(EPtr.box(texture.loadValue().width), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(texture.loadValue().width), 1);
}
});
this._map.set(
@@ -1763,7 +1783,8 @@
`native void GetDimensions(RWTexture1D<${type}${length}>,float* thread Width)`,
func => {
func.implementation = function([texture, width]) {
- width.loadValue().copyFrom(EPtr.box(texture.loadValue().width), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(texture.loadValue().width), 1);
}
});
this._map.set(
@@ -1786,8 +1807,10 @@
func => {
func.implementation = function([texture, width, elements]) {
let tex = texture.loadValue();
- elements.loadValue().copyFrom(EPtr.box(tex.layerCount), 1);
- width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (elements.loadValue())
+ elements.loadValue().copyFrom(EPtr.box(tex.layerCount), 1);
}
});
this._map.set(
@@ -1795,8 +1818,10 @@
func => {
func.implementation = function([texture, width, elements]) {
let tex = texture.loadValue();
- elements.loadValue().copyFrom(EPtr.box(tex.layerCount), 1);
- width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (elements.loadValue())
+ elements.loadValue().copyFrom(EPtr.box(tex.layerCount), 1);
}
});
this._map.set(
@@ -1819,8 +1844,10 @@
func => {
func.implementation = function([texture, width, height]) {
let tex = texture.loadValue();
- height.loadValue().copyFrom(EPtr.box(tex.height), 1);
- width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (height.loadValue())
+ height.loadValue().copyFrom(EPtr.box(tex.height), 1);
}
});
this._map.set(
@@ -1828,8 +1855,10 @@
func => {
func.implementation = function([texture, width, height]) {
let tex = texture.loadValue();
- height.loadValue().copyFrom(EPtr.box(tex.height), 1);
- width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (height.loadValue())
+ height.loadValue().copyFrom(EPtr.box(tex.height), 1);
}
});
this._map.set(
@@ -1852,9 +1881,12 @@
func => {
func.implementation = function([texture, width, height, elements]) {
let tex = texture.loadValue();
- elements.loadValue().copyFrom(EPtr.box(tex.layerCount), 1);
- height.loadValue().copyFrom(EPtr.box(tex.height), 1);
- width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (height.loadValue())
+ height.loadValue().copyFrom(EPtr.box(tex.height), 1);
+ if (elements.loadValue())
+ elements.loadValue().copyFrom(EPtr.box(tex.layerCount), 1);
}
});
this._map.set(
@@ -1862,9 +1894,12 @@
func => {
func.implementation = function([texture, width, height, elements]) {
let tex = texture.loadValue();
- elements.loadValue().copyFrom(EPtr.box(tex.layerCount), 1);
- height.loadValue().copyFrom(EPtr.box(tex.height), 1);
- width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (height.loadValue())
+ height.loadValue().copyFrom(EPtr.box(tex.height), 1);
+ if (elements.loadValue())
+ elements.loadValue().copyFrom(EPtr.box(tex.layerCount), 1);
}
});
this._map.set(
@@ -1887,9 +1922,12 @@
func => {
func.implementation = function([texture, width, height, depth]) {
let tex = texture.loadValue();
- depth.loadValue().copyFrom(EPtr.box(tex.depth), 1);
- height.loadValue().copyFrom(EPtr.box(tex.height), 1);
- width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (height.loadValue())
+ height.loadValue().copyFrom(EPtr.box(tex.height), 1);
+ if (depth.loadValue())
+ depth.loadValue().copyFrom(EPtr.box(tex.depth), 1);
}
});
this._map.set(
@@ -1897,9 +1935,12 @@
func => {
func.implementation = function([texture, width, height, depth]) {
let tex = texture.loadValue();
- depth.loadValue().copyFrom(EPtr.box(tex.depth), 1);
- height.loadValue().copyFrom(EPtr.box(tex.height), 1);
- width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (height.loadValue())
+ height.loadValue().copyFrom(EPtr.box(tex.height), 1);
+ if (depth.loadValue())
+ depth.loadValue().copyFrom(EPtr.box(tex.depth), 1);
}
});
this._map.set(
@@ -2116,9 +2157,12 @@
let mipID = miplevel.loadValue();
if (mipID >= tex.levelCount)
throw new WTrapError("[GetDimensions]", "Reading from nonexistant mip level of texture");
- height.loadValue().copyFrom(EPtr.box(tex.heightAtLevel(mipID)), 1);
- width.loadValue().copyFrom(EPtr.box(tex.widthAtLevel(mipID)), 1);
- numberOfLevels.loadValue().copyFrom(EPtr.box(tex.levelCount), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.widthAtLevel(mipID)), 1);
+ if (height.loadValue())
+ height.loadValue().copyFrom(EPtr.box(tex.heightAtLevel(mipID)), 1);
+ if (numberOfLevels.loadValue())
+ numberOfLevels.loadValue().copyFrom(EPtr.box(tex.levelCount), 1);
}
});
this._map.set(
@@ -2317,10 +2361,14 @@
let mipID = miplevel.loadValue();
if (mipID >= tex.levelCount)
throw new WTrapError("[GetDimensions]", "Reading from nonexistant mip level of texture");
- height.loadValue().copyFrom(EPtr.box(tex.heightAtLevel(mipID)), 1);
- width.loadValue().copyFrom(EPtr.box(tex.widthAtLevel(mipID)), 1);
- elements.loadValue().copyFrom(EPtr.box(tex.layerCount), 1);
- numberOfLevels.loadValue().copyFrom(EPtr.box(tex.levelCount), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.widthAtLevel(mipID)), 1);
+ if (height.loadValue())
+ height.loadValue().copyFrom(EPtr.box(tex.heightAtLevel(mipID)), 1);
+ if (elements.loadValue())
+ elements.loadValue().copyFrom(EPtr.box(tex.layerCount), 1);
+ if (numberOfLevels.loadValue())
+ numberOfLevels.loadValue().copyFrom(EPtr.box(tex.levelCount), 1);
}
});
this._map.set(
@@ -2415,9 +2463,12 @@
throw new Error("Cube texture doesn't have 6 faces");
if (mipID >= tex.levelCount)
throw new WTrapError("[GetDimensions]", "Reading from nonexistant mip level of texture");
- height.loadValue().copyFrom(EPtr.box(tex.heightAtLevel(mipID)), 1);
- width.loadValue().copyFrom(EPtr.box(tex.widthAtLevel(mipID)), 1);
- numberOfLevels.loadValue().copyFrom(EPtr.box(tex.levelCount), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.widthAtLevel(mipID)), 1);
+ if (height.loadValue())
+ height.loadValue().copyFrom(EPtr.box(tex.heightAtLevel(mipID)), 1);
+ if (numberOfLevels.loadValue())
+ numberOfLevels.loadValue().copyFrom(EPtr.box(tex.levelCount), 1);
}
});
this._map.set(
@@ -2425,8 +2476,10 @@
func => {
func.implementation = function ([texture, width, height]) {
let tex = texture.loadValue();
- height.loadValue().copyFrom(EPtr.box(tex.height), 1);
- width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (height.loadValue())
+ height.loadValue().copyFrom(EPtr.box(tex.height), 1);
}
});
this._map.set(
@@ -2434,8 +2487,10 @@
func => {
func.implementation = function ([texture, width, height]) {
let tex = texture.loadValue();
- height.loadValue().copyFrom(EPtr.box(tex.height), 1);
- width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (height.loadValue())
+ height.loadValue().copyFrom(EPtr.box(tex.height), 1);
}
});
this._map.set(
@@ -2457,9 +2512,12 @@
func => {
func.implementation = function ([texture, width, height, elements]) {
let tex = texture.loadValue();
- elements.loadValue().copyFrom(EPtr.box(tex.layerCount), 1);
- height.loadValue().copyFrom(EPtr.box(tex.height), 1);
- width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (height.loadValue())
+ height.loadValue().copyFrom(EPtr.box(tex.height), 1);
+ if (elements.loadValue())
+ elements.loadValue().copyFrom(EPtr.box(tex.layerCount), 1);
}
});
this._map.set(
@@ -2467,9 +2525,12 @@
func => {
func.implementation = function ([texture, width, height, elements]) {
let tex = texture.loadValue();
- elements.loadValue().copyFrom(EPtr.box(tex.layerCount), 1);
- height.loadValue().copyFrom(EPtr.box(tex.height), 1);
- width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (width.loadValue())
+ width.loadValue().copyFrom(EPtr.box(tex.width), 1);
+ if (height.loadValue())
+ height.loadValue().copyFrom(EPtr.box(tex.height), 1);
+ if (elements.loadValue())
+ elements.loadValue().copyFrom(EPtr.box(tex.layerCount), 1);
}
});
this._map.set(
Modified: trunk/Tools/WebGPUShadingLanguageRI/Test.js (236387 => 236388)
--- trunk/Tools/WebGPUShadingLanguageRI/Test.js 2018-09-22 23:22:55 UTC (rev 236387)
+++ trunk/Tools/WebGPUShadingLanguageRI/Test.js 2018-09-22 23:34:50 UTC (rev 236388)
@@ -7330,6 +7330,99 @@
checkUint(program, callFunction(program, "foo45", [rwTextureDepth2DArray]), 2);
}
+tests.textureDimensionsNull = function() {
+ let program = doPrep(`
+ test bool foo1(Texture1D<float> texture) {
+ GetDimensions(texture, 0, null, null);
+ return true;
+ }
+ test bool foo2(Texture1DArray<float> texture) {
+ GetDimensions(texture, 0, null, null, null);
+ return true;
+ }
+ test bool foo3(Texture2D<float> texture) {
+ GetDimensions(texture, 0, null, null, null);
+ return true;
+ }
+ test bool foo4(Texture2DArray<float> texture) {
+ GetDimensions(texture, 0, null, null, null, null);
+ return true;
+ }
+ test bool foo5(Texture3D<float> texture) {
+ GetDimensions(texture, 0, null, null, null, null);
+ return true;
+ }
+ test bool foo6(TextureCube<float> texture) {
+ GetDimensions(texture, 0, null, null, null);
+ return true;
+ }
+ test bool foo7(RWTexture1D<float> texture) {
+ thread float* ptr = null;
+ GetDimensions(texture, ptr);
+ return true;
+ }
+ test bool foo8(RWTexture1DArray<float> texture) {
+ thread uint* ptr = null;
+ GetDimensions(texture, ptr, ptr);
+ return true;
+ }
+ test bool foo9(RWTexture2D<float> texture) {
+ thread uint* ptr = null;
+ GetDimensions(texture, ptr, ptr);
+ return true;
+ }
+ test bool foo10(RWTexture2DArray<float> texture) {
+ thread uint* ptr = null;
+ GetDimensions(texture, ptr, ptr, ptr);
+ return true;
+ }
+ test bool foo11(RWTexture3D<float> texture) {
+ thread uint* ptr = null;
+ GetDimensions(texture, ptr, ptr, ptr);
+ return true;
+ }
+ test bool foo12(TextureDepth2D<float> texture) {
+ GetDimensions(texture, 0, null, null, null);
+ return true;
+ }
+ test bool foo13(TextureDepth2DArray<float> texture) {
+ GetDimensions(texture, 0, null, null, null, null);
+ return true;
+ }
+ test bool foo14(TextureDepthCube<float> texture) {
+ GetDimensions(texture, 0, null, null, null);
+ return true;
+ }
+ test bool foo15(RWTextureDepth2D<float> texture) {
+ thread uint* ptr = null;
+ GetDimensions(texture, ptr, ptr);
+ return true;
+ }
+ test bool foo16(RWTextureDepth2DArray<float> texture) {
+ thread uint* ptr = null;
+ GetDimensions(texture, ptr, ptr, ptr);
+ return true;
+ }
+ `);
+ let [texture1D, texture1DArray, texture2D, texture2DArray, texture3D, textureCube, rwTexture1D, rwTexture1DArray, rwTexture2D, rwTexture2DArray, rwTexture3D, textureDepth2D, textureDepth2DArray, textureDepthCube, rwTextureDepth2D, rwTextureDepth2DArray] = createTexturesForTesting(program);
+ checkBool(program, callFunction(program, "foo1", [texture1D]), true);
+ checkBool(program, callFunction(program, "foo2", [texture1DArray]), true);
+ checkBool(program, callFunction(program, "foo3", [texture2D]), true);
+ checkBool(program, callFunction(program, "foo4", [texture2DArray]), true);
+ checkBool(program, callFunction(program, "foo5", [texture3D]), true);
+ checkBool(program, callFunction(program, "foo6", [textureCube]), true);
+ checkBool(program, callFunction(program, "foo7", [rwTexture1D]), true);
+ checkBool(program, callFunction(program, "foo8", [rwTexture1DArray]), true);
+ checkBool(program, callFunction(program, "foo9", [rwTexture2D]), true);
+ checkBool(program, callFunction(program, "foo10", [rwTexture2DArray]), true);
+ checkBool(program, callFunction(program, "foo11", [rwTexture3D]), true);
+ checkBool(program, callFunction(program, "foo12", [textureDepth2D]), true);
+ checkBool(program, callFunction(program, "foo13", [textureDepth2DArray]), true);
+ checkBool(program, callFunction(program, "foo14", [textureDepthCube]), true);
+ checkBool(program, callFunction(program, "foo15", [rwTextureDepth2D]), true);
+ checkBool(program, callFunction(program, "foo16", [rwTextureDepth2DArray]), true);
+}
+
tests.textureLoad = function() {
let program = doPrep(`
test float foo1(Texture1D<float> texture, int location, int mipmap) {