Title: [249453] trunk
Revision
249453
Author
mmaxfi...@apple.com
Date
2019-09-03 20:30:21 -0700 (Tue, 03 Sep 2019)

Log Message

[WHLSL] Implement SampleLevel(), SampleBias(), and SampleGrad()
https://bugs.webkit.org/show_bug.cgi?id=201385

Reviewed by Dean Jackson.

Source/WebCore:

These are used in the Babylon.js demo.

Tests: webgpu/whlsl/textures-sample-bias.html
       webgpu/whlsl/textures-sample-grad.html
       webgpu/whlsl/textures-sample-level.html

* Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h:
* Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:
(WebCore::WHLSL::Metal::sampleType):
(WebCore::WHLSL::Metal::inlineNativeFunction):
* Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp:
(WebCore::WHLSL::Intrinsics::addFullTexture):
(WebCore::WHLSL::Intrinsics::addDepthTexture):
* Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt:

LayoutTests:

* webgpu/whlsl/textures-sample-bias-expected.html: Added.
* webgpu/whlsl/textures-sample-bias.html: Added.
* webgpu/whlsl/textures-sample-grad-expected.html: Added.
* webgpu/whlsl/textures-sample-grad.html: Added.
* webgpu/whlsl/textures-sample-level-expected.html: Added.
* webgpu/whlsl/textures-sample-level.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (249452 => 249453)


--- trunk/LayoutTests/ChangeLog	2019-09-04 03:13:45 UTC (rev 249452)
+++ trunk/LayoutTests/ChangeLog	2019-09-04 03:30:21 UTC (rev 249453)
@@ -1,3 +1,17 @@
+2019-09-03  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [WHLSL] Implement SampleLevel(), SampleBias(), and SampleGrad()
+        https://bugs.webkit.org/show_bug.cgi?id=201385
+
+        Reviewed by Dean Jackson.
+
+        * webgpu/whlsl/textures-sample-bias-expected.html: Added.
+        * webgpu/whlsl/textures-sample-bias.html: Added.
+        * webgpu/whlsl/textures-sample-grad-expected.html: Added.
+        * webgpu/whlsl/textures-sample-grad.html: Added.
+        * webgpu/whlsl/textures-sample-level-expected.html: Added.
+        * webgpu/whlsl/textures-sample-level.html: Added.
+
 2019-09-03  Devin Rousso  <drou...@apple.com>
 
         Web Inspector: implement blackboxing of script resources

Added: trunk/LayoutTests/webgpu/whlsl/textures-sample-bias-expected.html (0 => 249453)


--- trunk/LayoutTests/webgpu/whlsl/textures-sample-bias-expected.html	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl/textures-sample-bias-expected.html	2019-09-04 03:30:21 UTC (rev 249453)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<canvas id="canvas" width="400" height="400"></canvas>
+<script>
+const canvas = document.getElementById("canvas");
+drawWhiteSquareOnBlueBackgroundInSoftware(canvas);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/webgpu/whlsl/textures-sample-bias.html (0 => 249453)


--- trunk/LayoutTests/webgpu/whlsl/textures-sample-bias.html	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl/textures-sample-bias.html	2019-09-04 03:30:21 UTC (rev 249453)
@@ -0,0 +1,172 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<canvas id="canvas" width="400" height="400"></canvas>
+<script>
+const shaderSource = `
+struct Intermediate {
+    float4 position : SV_Position;
+    float2 textureCoordinate : attribute(0);
+}
+
+vertex Intermediate vertexShader(float4 position : attribute(0), float2 textureCoordinate : attribute(1)) {
+    Intermediate result;
+    result.position = position;
+    result.textureCoordinate = textureCoordinate;
+    return result;
+}
+
+fragment float4 fragmentShader(float2 textureCoordinate : attribute(0), Texture2D<float4> theTexture : register(t0), sampler theSampler : register(s1)) : SV_Target 0 {
+    return SampleBias(theTexture, theSampler, textureCoordinate, 1);
+}
+`;
+
+const canvas = document.getElementById("canvas");
+
+async function start(device) {
+    const shaderModule = device.createShaderModule({code: shaderSource});
+    const vertexStage = {module: shaderModule, entryPoint: "vertexShader"};
+    const fragmentStage = {module: shaderModule, entryPoint: "fragmentShader"};
+    const primitiveTopology = "triangle-strip";
+    const rasterizationState = {frontFace: "cw", cullMode: "none"};
+    const alphaBlend = {};
+    const colorBlend = {};
+    const colorStates = [{format: "rgba8unorm", alphaBlend, colorBlend, writeMask: 15}]; // GPUColorWriteBits.ALL
+    const depthStencilState = null;
+    
+    const attribute0 = {shaderLocation: 0, format: "float4"};
+    const input0 = {stride: Float32Array.BYTES_PER_ELEMENT * 4, attributeSet: [attribute0]};
+    const attribute1 = {shaderLocation: 1, format: "float2"};
+    const input1 = {stride: Float32Array.BYTES_PER_ELEMENT * 2, attributeSet: [attribute1]};
+    const inputs = [input0, input1];
+    const vertexInput = {vertexBuffers: inputs};
+
+    const bindGroupLayoutDescriptor = {bindings: [{binding: 0, visibility: 7, type: "sampled-texture"}, {binding: 1, visibility: 7, type: "sampler"}]};
+    const bindGroupLayout = device.createBindGroupLayout(bindGroupLayoutDescriptor);
+    const pipelineLayoutDescriptor = {bindGroupLayouts: [bindGroupLayout]};
+    const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor);
+
+    const renderPipelineDescriptor = {vertexStage, fragmentStage, primitiveTopology, rasterizationState, colorStates, depthStencilState, vertexInput, sampleCount: 1, layout: pipelineLayout};
+    const renderPipeline = device.createRenderPipeline(renderPipelineDescriptor);
+
+    const vertexBuffer0Descriptor = {size: Float32Array.BYTES_PER_ELEMENT * 4 * 4 + Float32Array.BYTES_PER_ELEMENT * 2 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.MAP_WRITE};
+    const vertexBuffer0 = device.createBuffer(vertexBuffer0Descriptor);
+    const vertexBuffer0ArrayBuffer = await vertexBuffer0.mapWriteAsync();
+    const vertexBuffer0Float32Array = new Float32Array(vertexBuffer0ArrayBuffer);
+    vertexBuffer0Float32Array[0] = -0.5;
+    vertexBuffer0Float32Array[1] = -0.5;
+    vertexBuffer0Float32Array[2] = 1.0;
+    vertexBuffer0Float32Array[3] = 1;
+    vertexBuffer0Float32Array[4] = -0.5;
+    vertexBuffer0Float32Array[5] = 0.5;
+    vertexBuffer0Float32Array[6] = 1.0;
+    vertexBuffer0Float32Array[7] = 1;
+    vertexBuffer0Float32Array[8] = 0.5;
+    vertexBuffer0Float32Array[9] = -0.5;
+    vertexBuffer0Float32Array[10] = 1.0;
+    vertexBuffer0Float32Array[11] = 1;
+    vertexBuffer0Float32Array[12] = 0.5;
+    vertexBuffer0Float32Array[13] = 0.5;
+    vertexBuffer0Float32Array[14] = 1.0;
+    vertexBuffer0Float32Array[15] = 1;
+    vertexBuffer0Float32Array[16] = 0;
+    vertexBuffer0Float32Array[17] = 0;
+    vertexBuffer0Float32Array[18] = 0;
+    vertexBuffer0Float32Array[19] = 100;
+    vertexBuffer0Float32Array[20] = 100;
+    vertexBuffer0Float32Array[21] = 0;
+    vertexBuffer0Float32Array[22] = 100;
+    vertexBuffer0Float32Array[23] = 100;
+    vertexBuffer0.unmap();
+
+    const textureDataBufferDescriptor = {size: Uint8Array.BYTES_PER_ELEMENT * 4 * 2 * 2 + Uint8Array.BYTES_PER_ELEMENT * 4 * 1 * 1, usage: GPUBufferUsage.TRANSFER_SRC | GPUBufferUsage.MAP_WRITE};
+    const textureDataBuffer = device.createBuffer(textureDataBufferDescriptor);
+    const textureDataBufferArrayBuffer = await textureDataBuffer.mapWriteAsync();
+    const textureDataBufferUint8Array = new Uint8Array(textureDataBufferArrayBuffer);
+    textureDataBufferUint8Array[0] = 255;
+    textureDataBufferUint8Array[1] = 0;
+    textureDataBufferUint8Array[2] = 0;
+    textureDataBufferUint8Array[3] = 255;
+    textureDataBufferUint8Array[4] = 0;
+    textureDataBufferUint8Array[5] = 255;
+    textureDataBufferUint8Array[6] = 0;
+    textureDataBufferUint8Array[7] = 255;
+    textureDataBufferUint8Array[8] = 0;
+    textureDataBufferUint8Array[9] = 255
+    textureDataBufferUint8Array[10] = 0;
+    textureDataBufferUint8Array[11] = 255;
+    textureDataBufferUint8Array[12] = 255
+    textureDataBufferUint8Array[13] = 0;
+    textureDataBufferUint8Array[14] = 0;
+    textureDataBufferUint8Array[15] = 255;
+    textureDataBufferUint8Array[16] = 255;
+    textureDataBufferUint8Array[17] = 255;
+    textureDataBufferUint8Array[18] = 255;
+    textureDataBufferUint8Array[19] = 255;
+    textureDataBuffer.unmap();
+
+    const textureDescriptor = {size: {width: 2, height: 2, depth: 1}, mipLevelCount: 2, format: "rgba8unorm", usage: GPUTextureUsage.SAMPLED | GPUTextureUsage.TRANSFER_DST};
+    const texture = device.createTexture(textureDescriptor);
+    const textureView = texture.createDefaultView();
+
+    const samplerDescriptor = {addressModeU: "repeat", addressModeV: "repeat", addressModeW: "repeat", magFilter: "linear", minFilter: "linear"};
+    const sampler = device.createSampler(samplerDescriptor);
+
+    const bindGroupBindings = [{binding: 0, resource: textureView}, {binding: 1, resource: sampler}];
+    const bindGroupDescriptor = {layout: bindGroupLayout, bindings: bindGroupBindings};
+    const bindGroup = device.createBindGroup(bindGroupDescriptor);
+
+    const context = canvas.getContext("gpu");
+    const swapChainDescriptor = {device, format: "bgra8unorm"};
+    const swapChain = context.configureSwapChain(swapChainDescriptor);
+    const outputTexture = swapChain.getCurrentTexture();
+    const outputTextureView = outputTexture.createDefaultView();
+
+    const commandEncoder = device.createCommandEncoder(); // {}
+
+    const bufferCopy1View = {buffer: textureDataBuffer, rowPitch: Uint8Array.BYTES_PER_ELEMENT * 4 * 2, imageHeight: Uint8Array.BYTES_PER_ELEMENT * 4 * 2 * 2};
+    const textureCopy1View = {texture: texture};
+    const copy1Size = {width: 2, height: 2, depth: 1};
+    commandEncoder.copyBufferToTexture(bufferCopy1View, textureCopy1View, copy1Size);
+    const bufferCopy2View = {buffer: textureDataBuffer, offset: Uint8Array.BYTES_PER_ELEMENT * 4 * 2 * 2, rowPitch: Uint8Array.BYTES_PER_ELEMENT * 4 * 1, imageHeight: Uint8Array.BYTES_PER_ELEMENT * 4 * 1 * 1};
+    const textureCopy2View = {texture: texture, mipLevel: 1};
+    const copy2Size = {width: 1, height: 1, depth: 1};
+    commandEncoder.copyBufferToTexture(bufferCopy2View, textureCopy2View, copy2Size);
+
+    const clearColor = {r: 0, g: 0, b: 1, a: 1};
+    const colorAttachments = [{attachment: outputTextureView, resolveTarget: null, loadOp: "clear", storeOp: "store", clearColor}];
+    const depthStencilAttachment = null;
+    const renderPassDescriptor = {colorAttachments, depthStencilAttachment};
+    const renderPassEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
+    renderPassEncoder.setPipeline(renderPipeline);
+    renderPassEncoder.setBindGroup(0, bindGroup);
+    renderPassEncoder.setVertexBuffers(0, [vertexBuffer0, vertexBuffer0], [0, Float32Array.BYTES_PER_ELEMENT * 4 * 4]);
+    renderPassEncoder.draw(4, 1, 0, 0);
+    renderPassEncoder.endPass();
+    const commandBuffer = commandEncoder.finish();
+    device.getQueue().submit([commandBuffer]);
+
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+if (window.testRunner)
+    testRunner.waitUntilDone();
+getBasicDevice().then(function(device) {
+    start(device).then(function() {
+        if (window.testRunner)
+            testRunner.notifyDone();
+    }, function() {
+        if (window.testRunner)
+            testRunner.notifyDone();
+    });
+}, function() {
+    drawWhiteSquareOnBlueBackgroundInSoftware(canvas);
+    if (window.testRunner)
+        testRunner.notifyDone();
+});
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/webgpu/whlsl/textures-sample-grad-expected.html (0 => 249453)


--- trunk/LayoutTests/webgpu/whlsl/textures-sample-grad-expected.html	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl/textures-sample-grad-expected.html	2019-09-04 03:30:21 UTC (rev 249453)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<canvas id="canvas" width="400" height="400"></canvas>
+<script>
+const canvas = document.getElementById("canvas");
+drawWhiteSquareOnBlueBackgroundInSoftware(canvas);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/webgpu/whlsl/textures-sample-grad.html (0 => 249453)


--- trunk/LayoutTests/webgpu/whlsl/textures-sample-grad.html	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl/textures-sample-grad.html	2019-09-04 03:30:21 UTC (rev 249453)
@@ -0,0 +1,154 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<canvas id="canvas" width="400" height="400"></canvas>
+<script>
+const shaderSource = `
+vertex float4 vertexShader(float4 position : attribute(0)) : SV_Position {
+    return position;
+}
+
+fragment float4 fragmentShader(Texture2D<float4> theTexture : register(t0), sampler theSampler : register(s1)) : SV_Target 0 {
+    return SampleGrad(theTexture, theSampler, float2(0.5, 0.5), float2(1, 0), float2(0, 1));
+}
+`;
+
+const canvas = document.getElementById("canvas");
+
+async function start(device) {
+    const shaderModule = device.createShaderModule({code: shaderSource});
+    const vertexStage = {module: shaderModule, entryPoint: "vertexShader"};
+    const fragmentStage = {module: shaderModule, entryPoint: "fragmentShader"};
+    const primitiveTopology = "triangle-strip";
+    const rasterizationState = {frontFace: "cw", cullMode: "none"};
+    const alphaBlend = {};
+    const colorBlend = {};
+    const colorStates = [{format: "rgba8unorm", alphaBlend, colorBlend, writeMask: 15}]; // GPUColorWriteBits.ALL
+    const depthStencilState = null;
+    
+    const attribute0 = {shaderLocation: 0, format: "float4"};
+    const input0 = {stride: 16, attributeSet: [attribute0]};
+    const inputs = [input0];
+    const vertexInput = {vertexBuffers: inputs};
+
+    const bindGroupLayoutDescriptor = {bindings: [{binding: 0, visibility: 7, type: "sampled-texture"}, {binding: 1, visibility: 7, type: "sampler"}]};
+    const bindGroupLayout = device.createBindGroupLayout(bindGroupLayoutDescriptor);
+    const pipelineLayoutDescriptor = {bindGroupLayouts: [bindGroupLayout]};
+    const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor);
+
+    const renderPipelineDescriptor = {vertexStage, fragmentStage, primitiveTopology, rasterizationState, colorStates, depthStencilState, vertexInput, sampleCount: 1, layout: pipelineLayout};
+    const renderPipeline = device.createRenderPipeline(renderPipelineDescriptor);
+
+    const vertexBuffer0Descriptor = {size: Float32Array.BYTES_PER_ELEMENT * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.MAP_WRITE};
+    const vertexBuffer0 = device.createBuffer(vertexBuffer0Descriptor);
+    const vertexBuffer0ArrayBuffer = await vertexBuffer0.mapWriteAsync();
+    const vertexBuffer0Float32Array = new Float32Array(vertexBuffer0ArrayBuffer);
+    vertexBuffer0Float32Array[0] = -0.5;
+    vertexBuffer0Float32Array[1] = -0.5;
+    vertexBuffer0Float32Array[2] = 1.0;
+    vertexBuffer0Float32Array[3] = 1;
+    vertexBuffer0Float32Array[4] = -0.5;
+    vertexBuffer0Float32Array[5] = 0.5;
+    vertexBuffer0Float32Array[6] = 1.0;
+    vertexBuffer0Float32Array[7] = 1;
+    vertexBuffer0Float32Array[8] = 0.5;
+    vertexBuffer0Float32Array[9] = -0.5;
+    vertexBuffer0Float32Array[10] = 1.0;
+    vertexBuffer0Float32Array[11] = 1;
+    vertexBuffer0Float32Array[12] = 0.5;
+    vertexBuffer0Float32Array[13] = 0.5;
+    vertexBuffer0Float32Array[14] = 1.0;
+    vertexBuffer0Float32Array[15] = 1;
+    vertexBuffer0.unmap();
+
+    const textureDataBufferDescriptor = {size: Uint8Array.BYTES_PER_ELEMENT * 4 * 2 * 2 + Uint8Array.BYTES_PER_ELEMENT * 4 * 1 * 1, usage: GPUBufferUsage.TRANSFER_SRC | GPUBufferUsage.MAP_WRITE};
+    const textureDataBuffer = device.createBuffer(textureDataBufferDescriptor);
+    const textureDataBufferArrayBuffer = await textureDataBuffer.mapWriteAsync();
+    const textureDataBufferUint8Array = new Uint8Array(textureDataBufferArrayBuffer);
+    textureDataBufferUint8Array[0] = 255;
+    textureDataBufferUint8Array[1] = 0;
+    textureDataBufferUint8Array[2] = 0;
+    textureDataBufferUint8Array[3] = 255;
+    textureDataBufferUint8Array[4] = 255;
+    textureDataBufferUint8Array[5] = 0;
+    textureDataBufferUint8Array[6] = 0;
+    textureDataBufferUint8Array[7] = 255;
+    textureDataBufferUint8Array[8] = 255;
+    textureDataBufferUint8Array[9] = 0;
+    textureDataBufferUint8Array[10] = 0;
+    textureDataBufferUint8Array[11] = 255;
+    textureDataBufferUint8Array[12] = 255;
+    textureDataBufferUint8Array[13] = 0;
+    textureDataBufferUint8Array[14] = 0;
+    textureDataBufferUint8Array[15] = 255;
+    textureDataBufferUint8Array[16] = 255;
+    textureDataBufferUint8Array[17] = 255;
+    textureDataBufferUint8Array[18] = 255;
+    textureDataBufferUint8Array[19] = 255;
+    textureDataBuffer.unmap();
+
+    const textureDescriptor = {size: {width: 2, height: 2, depth: 1}, mipLevelCount: 2, format: "rgba8unorm", usage: GPUTextureUsage.SAMPLED | GPUTextureUsage.TRANSFER_DST};
+    const texture = device.createTexture(textureDescriptor);
+    const textureView = texture.createDefaultView();
+
+    const samplerDescriptor = {magFilter: "linear", minFilter: "linear"};
+    const sampler = device.createSampler(samplerDescriptor);
+
+    const bindGroupBindings = [{binding: 0, resource: textureView}, {binding: 1, resource: sampler}];
+    const bindGroupDescriptor = {layout: bindGroupLayout, bindings: bindGroupBindings};
+    const bindGroup = device.createBindGroup(bindGroupDescriptor);
+
+    const context = canvas.getContext("gpu");
+    const swapChainDescriptor = {device, format: "bgra8unorm"};
+    const swapChain = context.configureSwapChain(swapChainDescriptor);
+    const outputTexture = swapChain.getCurrentTexture();
+    const outputTextureView = outputTexture.createDefaultView();
+
+    const commandEncoder = device.createCommandEncoder(); // {}
+
+    const bufferCopy1View = {buffer: textureDataBuffer, rowPitch: Uint8Array.BYTES_PER_ELEMENT * 4 * 2, imageHeight: Uint8Array.BYTES_PER_ELEMENT * 4 * 2 * 2};
+    const textureCopy1View = {texture: texture};
+    const copy1Size = {width: 2, height: 2, depth: 1};
+    commandEncoder.copyBufferToTexture(bufferCopy1View, textureCopy1View, copy1Size);
+    const bufferCopy2View = {buffer: textureDataBuffer, offset: Uint8Array.BYTES_PER_ELEMENT * 4 * 2 * 2, rowPitch: Uint8Array.BYTES_PER_ELEMENT * 4 * 1, imageHeight: Uint8Array.BYTES_PER_ELEMENT * 4 * 1 * 1};
+    const textureCopy2View = {texture: texture, mipLevel: 1};
+    const copy2Size = {width: 1, height: 1, depth: 1};
+    commandEncoder.copyBufferToTexture(bufferCopy2View, textureCopy2View, copy2Size);
+
+    const clearColor = {r: 0, g: 0, b: 1, a: 1};
+    const colorAttachments = [{attachment: outputTextureView, resolveTarget: null, loadOp: "clear", storeOp: "store", clearColor}];
+    const depthStencilAttachment = null;
+    const renderPassDescriptor = {colorAttachments, depthStencilAttachment};
+    const renderPassEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
+    renderPassEncoder.setPipeline(renderPipeline);
+    renderPassEncoder.setBindGroup(0, bindGroup);
+    renderPassEncoder.setVertexBuffers(0, [vertexBuffer0], [0]);
+    renderPassEncoder.draw(4, 1, 0, 0);
+    renderPassEncoder.endPass();
+    const commandBuffer = commandEncoder.finish();
+    device.getQueue().submit([commandBuffer]);
+
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+if (window.testRunner)
+    testRunner.waitUntilDone();
+getBasicDevice().then(function(device) {
+    start(device).then(function() {
+        if (window.testRunner)
+            testRunner.notifyDone();
+    }, function() {
+        if (window.testRunner)
+            testRunner.notifyDone();
+    });
+}, function() {
+    drawWhiteSquareOnBlueBackgroundInSoftware(canvas);
+    if (window.testRunner)
+        testRunner.notifyDone();
+});
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/webgpu/whlsl/textures-sample-level-expected.html (0 => 249453)


--- trunk/LayoutTests/webgpu/whlsl/textures-sample-level-expected.html	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl/textures-sample-level-expected.html	2019-09-04 03:30:21 UTC (rev 249453)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<canvas id="canvas" width="400" height="400"></canvas>
+<script>
+const canvas = document.getElementById("canvas");
+drawWhiteSquareOnBlueBackgroundInSoftware(canvas);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/webgpu/whlsl/textures-sample-level.html (0 => 249453)


--- trunk/LayoutTests/webgpu/whlsl/textures-sample-level.html	                        (rev 0)
+++ trunk/LayoutTests/webgpu/whlsl/textures-sample-level.html	2019-09-04 03:30:21 UTC (rev 249453)
@@ -0,0 +1,154 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<canvas id="canvas" width="400" height="400"></canvas>
+<script>
+const shaderSource = `
+vertex float4 vertexShader(float4 position : attribute(0)) : SV_Position {
+    return position;
+}
+
+fragment float4 fragmentShader(Texture2D<float4> theTexture : register(t0), sampler theSampler : register(s1)) : SV_Target 0 {
+    return SampleLevel(theTexture, theSampler, float2(0.5, 0.5), 1);
+}
+`;
+
+const canvas = document.getElementById("canvas");
+
+async function start(device) {
+    const shaderModule = device.createShaderModule({code: shaderSource});
+    const vertexStage = {module: shaderModule, entryPoint: "vertexShader"};
+    const fragmentStage = {module: shaderModule, entryPoint: "fragmentShader"};
+    const primitiveTopology = "triangle-strip";
+    const rasterizationState = {frontFace: "cw", cullMode: "none"};
+    const alphaBlend = {};
+    const colorBlend = {};
+    const colorStates = [{format: "rgba8unorm", alphaBlend, colorBlend, writeMask: 15}]; // GPUColorWriteBits.ALL
+    const depthStencilState = null;
+    
+    const attribute0 = {shaderLocation: 0, format: "float4"};
+    const input0 = {stride: 16, attributeSet: [attribute0]};
+    const inputs = [input0];
+    const vertexInput = {vertexBuffers: inputs};
+
+    const bindGroupLayoutDescriptor = {bindings: [{binding: 0, visibility: 7, type: "sampled-texture"}, {binding: 1, visibility: 7, type: "sampler"}]};
+    const bindGroupLayout = device.createBindGroupLayout(bindGroupLayoutDescriptor);
+    const pipelineLayoutDescriptor = {bindGroupLayouts: [bindGroupLayout]};
+    const pipelineLayout = device.createPipelineLayout(pipelineLayoutDescriptor);
+
+    const renderPipelineDescriptor = {vertexStage, fragmentStage, primitiveTopology, rasterizationState, colorStates, depthStencilState, vertexInput, sampleCount: 1, layout: pipelineLayout};
+    const renderPipeline = device.createRenderPipeline(renderPipelineDescriptor);
+
+    const vertexBuffer0Descriptor = {size: Float32Array.BYTES_PER_ELEMENT * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.MAP_WRITE};
+    const vertexBuffer0 = device.createBuffer(vertexBuffer0Descriptor);
+    const vertexBuffer0ArrayBuffer = await vertexBuffer0.mapWriteAsync();
+    const vertexBuffer0Float32Array = new Float32Array(vertexBuffer0ArrayBuffer);
+    vertexBuffer0Float32Array[0] = -0.5;
+    vertexBuffer0Float32Array[1] = -0.5;
+    vertexBuffer0Float32Array[2] = 1.0;
+    vertexBuffer0Float32Array[3] = 1;
+    vertexBuffer0Float32Array[4] = -0.5;
+    vertexBuffer0Float32Array[5] = 0.5;
+    vertexBuffer0Float32Array[6] = 1.0;
+    vertexBuffer0Float32Array[7] = 1;
+    vertexBuffer0Float32Array[8] = 0.5;
+    vertexBuffer0Float32Array[9] = -0.5;
+    vertexBuffer0Float32Array[10] = 1.0;
+    vertexBuffer0Float32Array[11] = 1;
+    vertexBuffer0Float32Array[12] = 0.5;
+    vertexBuffer0Float32Array[13] = 0.5;
+    vertexBuffer0Float32Array[14] = 1.0;
+    vertexBuffer0Float32Array[15] = 1;
+    vertexBuffer0.unmap();
+
+    const textureDataBufferDescriptor = {size: Uint8Array.BYTES_PER_ELEMENT * 4 * 2 * 2 + Uint8Array.BYTES_PER_ELEMENT * 4 * 1 * 1, usage: GPUBufferUsage.TRANSFER_SRC | GPUBufferUsage.MAP_WRITE};
+    const textureDataBuffer = device.createBuffer(textureDataBufferDescriptor);
+    const textureDataBufferArrayBuffer = await textureDataBuffer.mapWriteAsync();
+    const textureDataBufferUint8Array = new Uint8Array(textureDataBufferArrayBuffer);
+    textureDataBufferUint8Array[0] = 255;
+    textureDataBufferUint8Array[1] = 0;
+    textureDataBufferUint8Array[2] = 0;
+    textureDataBufferUint8Array[3] = 255;
+    textureDataBufferUint8Array[4] = 255;
+    textureDataBufferUint8Array[5] = 0;
+    textureDataBufferUint8Array[6] = 0;
+    textureDataBufferUint8Array[7] = 255;
+    textureDataBufferUint8Array[8] = 255;
+    textureDataBufferUint8Array[9] = 0;
+    textureDataBufferUint8Array[10] = 0;
+    textureDataBufferUint8Array[11] = 255;
+    textureDataBufferUint8Array[12] = 255;
+    textureDataBufferUint8Array[13] = 0;
+    textureDataBufferUint8Array[14] = 0;
+    textureDataBufferUint8Array[15] = 255;
+    textureDataBufferUint8Array[16] = 255;
+    textureDataBufferUint8Array[17] = 255;
+    textureDataBufferUint8Array[18] = 255;
+    textureDataBufferUint8Array[19] = 255;
+    textureDataBuffer.unmap();
+
+    const textureDescriptor = {size: {width: 2, height: 2, depth: 1}, mipLevelCount: 2, format: "rgba8unorm", usage: GPUTextureUsage.SAMPLED | GPUTextureUsage.TRANSFER_DST};
+    const texture = device.createTexture(textureDescriptor);
+    const textureView = texture.createDefaultView();
+
+    const samplerDescriptor = {magFilter: "linear", minFilter: "linear"};
+    const sampler = device.createSampler(samplerDescriptor);
+
+    const bindGroupBindings = [{binding: 0, resource: textureView}, {binding: 1, resource: sampler}];
+    const bindGroupDescriptor = {layout: bindGroupLayout, bindings: bindGroupBindings};
+    const bindGroup = device.createBindGroup(bindGroupDescriptor);
+
+    const context = canvas.getContext("gpu");
+    const swapChainDescriptor = {device, format: "bgra8unorm"};
+    const swapChain = context.configureSwapChain(swapChainDescriptor);
+    const outputTexture = swapChain.getCurrentTexture();
+    const outputTextureView = outputTexture.createDefaultView();
+
+    const commandEncoder = device.createCommandEncoder(); // {}
+
+    const bufferCopy1View = {buffer: textureDataBuffer, rowPitch: Uint8Array.BYTES_PER_ELEMENT * 4 * 2, imageHeight: Uint8Array.BYTES_PER_ELEMENT * 4 * 2 * 2};
+    const textureCopy1View = {texture: texture};
+    const copy1Size = {width: 2, height: 2, depth: 1};
+    commandEncoder.copyBufferToTexture(bufferCopy1View, textureCopy1View, copy1Size);
+    const bufferCopy2View = {buffer: textureDataBuffer, offset: Uint8Array.BYTES_PER_ELEMENT * 4 * 2 * 2, rowPitch: Uint8Array.BYTES_PER_ELEMENT * 4 * 1, imageHeight: Uint8Array.BYTES_PER_ELEMENT * 4 * 1 * 1};
+    const textureCopy2View = {texture: texture, mipLevel: 1};
+    const copy2Size = {width: 1, height: 1, depth: 1};
+    commandEncoder.copyBufferToTexture(bufferCopy2View, textureCopy2View, copy2Size);
+
+    const clearColor = {r: 0, g: 0, b: 1, a: 1};
+    const colorAttachments = [{attachment: outputTextureView, resolveTarget: null, loadOp: "clear", storeOp: "store", clearColor}];
+    const depthStencilAttachment = null;
+    const renderPassDescriptor = {colorAttachments, depthStencilAttachment};
+    const renderPassEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
+    renderPassEncoder.setPipeline(renderPipeline);
+    renderPassEncoder.setBindGroup(0, bindGroup);
+    renderPassEncoder.setVertexBuffers(0, [vertexBuffer0], [0]);
+    renderPassEncoder.draw(4, 1, 0, 0);
+    renderPassEncoder.endPass();
+    const commandBuffer = commandEncoder.finish();
+    device.getQueue().submit([commandBuffer]);
+
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+if (window.testRunner)
+    testRunner.waitUntilDone();
+getBasicDevice().then(function(device) {
+    start(device).then(function() {
+        if (window.testRunner)
+            testRunner.notifyDone();
+    }, function() {
+        if (window.testRunner)
+            testRunner.notifyDone();
+    });
+}, function() {
+    drawWhiteSquareOnBlueBackgroundInSoftware(canvas);
+    if (window.testRunner)
+        testRunner.notifyDone();
+});
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (249452 => 249453)


--- trunk/Source/WebCore/ChangeLog	2019-09-04 03:13:45 UTC (rev 249452)
+++ trunk/Source/WebCore/ChangeLog	2019-09-04 03:30:21 UTC (rev 249453)
@@ -1,3 +1,25 @@
+2019-09-03  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [WHLSL] Implement SampleLevel(), SampleBias(), and SampleGrad()
+        https://bugs.webkit.org/show_bug.cgi?id=201385
+
+        Reviewed by Dean Jackson.
+
+        These are used in the Babylon.js demo.
+
+        Tests: webgpu/whlsl/textures-sample-bias.html
+               webgpu/whlsl/textures-sample-grad.html
+               webgpu/whlsl/textures-sample-level.html
+
+        * Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h:
+        * Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp:
+        (WebCore::WHLSL::Metal::sampleType):
+        (WebCore::WHLSL::Metal::inlineNativeFunction):
+        * Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp:
+        (WebCore::WHLSL::Intrinsics::addFullTexture):
+        (WebCore::WHLSL::Intrinsics::addDepthTexture):
+        * Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt:
+
 2019-09-03  Chris Dumez  <cdu...@apple.com>
 
         FrameLoader::FrameProgressTracker::progressCompleted() does not need a pageID

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h (249452 => 249453)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h	2019-09-04 03:13:45 UTC (rev 249452)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLNativeTypeDeclaration.h	2019-09-04 03:30:21 UTC (rev 249453)
@@ -67,6 +67,7 @@
     bool isTextureArray() const { return m_isTextureArray; }
     bool isDepthTexture() const { return m_isDepthTexture; }
     bool isWritableTexture() const { return m_isWritableTexture; }
+    bool isCubeTexture() const { return m_isCubeTexture; }
     uint textureDimension() const { return m_textureDimension; }
     bool isSigned() const { return m_isSigned; }
     const std::function<bool(int)>& canRepresentInteger() const { return m_canRepresentInteger; }
@@ -122,6 +123,7 @@
     void setIsTextureArray() { m_isTextureArray = true; }
     void setIsDepthTexture() { m_isDepthTexture = true; }
     void setIsWritableTexture() { m_isWritableTexture = true; }
+    void setIsCubeTexture() { m_isCubeTexture = true; }
     void setTextureDimension(uint textureDimension) { m_textureDimension = textureDimension; }
     void setIsSigned() { m_isSigned = true; }
     void setCanRepresentInteger(std::function<bool(int)>&& canRepresent) { m_canRepresentInteger = WTFMove(canRepresent); }
@@ -153,6 +155,7 @@
     bool m_isTextureArray { false };
     bool m_isDepthTexture { false };
     bool m_isWritableTexture { false };
+    bool m_isCubeTexture { false };
     bool m_isSigned { false };
 };
 

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp (249452 => 249453)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp	2019-09-04 03:13:45 UTC (rev 249452)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLNativeFunctionWriter.cpp	2019-09-04 03:30:21 UTC (rev 249453)
@@ -110,6 +110,26 @@
     }
 }
 
+enum class SampleType {
+    Sample,
+    SampleLevel,
+    SampleBias,
+    SampleGrad
+};
+
+static Optional<SampleType> sampleType(const String& functionName)
+{
+    if (functionName == "Sample")
+        return SampleType::Sample;
+    if (functionName == "SampleLevel")
+        return SampleType::SampleLevel;
+    if (functionName == "SampleBias")
+        return SampleType::SampleBias;
+    if (functionName == "SampleGrad")
+        return SampleType::SampleGrad;
+    return WTF::nullopt;
+}
+
 void inlineNativeFunction(StringBuilder& stringBuilder, AST::NativeFunctionDeclaration& nativeFunctionDeclaration, const Vector<MangledVariableName>& args, MangledVariableName resultName, TypeNamer& typeNamer)
 {
     auto asMatrixType = [&] (AST::UnnamedType& unnamedType) -> AST::NativeTypeDeclaration* {
@@ -343,8 +363,21 @@
         return;
     }
 
-    if (nativeFunctionDeclaration.name() == "Sample") {
-        ASSERT(nativeFunctionDeclaration.parameters().size() == 3 || nativeFunctionDeclaration.parameters().size() == 4);
+    if (auto sampleType = WHLSL::Metal::sampleType(nativeFunctionDeclaration.name())) {
+        size_t baseArgumentCount = 0;
+        switch (*sampleType) {
+        case SampleType::Sample:
+            baseArgumentCount = 3;
+            break;
+        case SampleType::SampleLevel:
+        case SampleType::SampleBias:
+            baseArgumentCount = 4;
+            break;
+        case SampleType::SampleGrad:
+            baseArgumentCount = 5;
+            break;
+        }
+        ASSERT(nativeFunctionDeclaration.parameters().size() == baseArgumentCount || nativeFunctionDeclaration.parameters().size() == baseArgumentCount + 1);
         
         auto& textureType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[0]->type()->unifyNode()));
         auto& locationType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.parameters()[2]->type()->unifyNode()));
@@ -352,16 +385,37 @@
         auto& returnType = downcast<AST::NativeTypeDeclaration>(downcast<AST::NamedType>(nativeFunctionDeclaration.type().unifyNode()));
         auto returnVectorLength = vectorLength(returnType);
 
-        stringBuilder.append(
-            args[0], ".sample(", args[1], ", ");
+        int argumentIndex = 0;
+        stringBuilder.append(args[argumentIndex], ".sample(", args[argumentIndex + 1], ", ");
+        argumentIndex += 2;
 
         if (textureType.isTextureArray()) {
             ASSERT(locationVectorLength > 1);
-            stringBuilder.append(args[2], '.', "xyzw"_str.substring(0, locationVectorLength - 1), ", ", args[2], '.', "xyzw"_str.substring(locationVectorLength - 1, 1));
+            stringBuilder.append(args[argumentIndex], '.', "xyzw"_str.substring(0, locationVectorLength - 1), ", ", args[argumentIndex], '.', "xyzw"_str.substring(locationVectorLength - 1, 1));
+            ++argumentIndex;
         } else
-            stringBuilder.append(args[2]);
-        if (nativeFunctionDeclaration.parameters().size() == 4)
-            stringBuilder.append(", ", args[3]);
+            stringBuilder.append(args[argumentIndex++]);
+
+        switch (*sampleType) {
+        case SampleType::Sample:
+            break;
+        case SampleType::SampleLevel:
+            stringBuilder.append(", level(", args[argumentIndex++], ")");
+            break;
+        case SampleType::SampleBias:
+            stringBuilder.append(", bias(", args[argumentIndex++], ")");
+            break;
+        case SampleType::SampleGrad:
+            if (textureType.isCubeTexture())
+                stringBuilder.append(", gradientcube(", args[argumentIndex], ", ", args[argumentIndex + 1], ")");
+            else
+                stringBuilder.append(", gradient2d(", args[argumentIndex], ", ", args[argumentIndex + 1], ")");
+            argumentIndex += 2;
+            break;
+        }
+
+        if (nativeFunctionDeclaration.parameters().size() == baseArgumentCount + 1)
+            stringBuilder.append(", ", args[argumentIndex++]);
         stringBuilder.append(")");
         if (!textureType.isDepthTexture())
             stringBuilder.append(".", "xyzw"_str.substring(0, returnVectorLength));
@@ -509,21 +563,6 @@
         return;
     }
 
-    if (nativeFunctionDeclaration.name() == "SampleBias") {
-        // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195813 Implement this
-        notImplemented();
-    }
-
-    if (nativeFunctionDeclaration.name() == "SampleGrad") {
-        // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195813 Implement this
-        notImplemented();
-    }
-
-    if (nativeFunctionDeclaration.name() == "SampleLevel") {
-        // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195813 Implement this
-        notImplemented();
-    }
-
     if (nativeFunctionDeclaration.name() == "Gather") {
         // FIXME: https://bugs.webkit.org/show_bug.cgi?id=195813 Implement this
         notImplemented();

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp (249452 => 249453)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp	2019-09-04 03:13:45 UTC (rev 249452)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp	2019-09-04 03:30:21 UTC (rev 249453)
@@ -231,6 +231,8 @@
         nativeTypeDeclaration.setTextureDimension(2);
     if (nativeTypeDeclaration.name() == "Texture3D" || nativeTypeDeclaration.name() == "RWTexture3D")
         nativeTypeDeclaration.setTextureDimension(3);
+    if (nativeTypeDeclaration.name() == "TextureCube")
+        nativeTypeDeclaration.setIsCubeTexture();
     m_fullTextures[textureTypeIndex][innerTypeIndex][vectorLength - 1] = &nativeTypeDeclaration;
     return true;
 }
@@ -252,6 +254,8 @@
     nativeTypeDeclaration.setIsOpaqueType();
     if (texture == m_textureDepth2DArray)
         nativeTypeDeclaration.setIsTextureArray();
+    if (texture == m_textureDepthCube)
+        nativeTypeDeclaration.setIsCubeTexture();
     nativeTypeDeclaration.setTextureDimension(2);
     nativeTypeDeclaration.setIsDepthTexture();
     texture[innerTypeIndex] = &nativeTypeDeclaration;

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt (249452 => 249453)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt	2019-09-04 03:13:45 UTC (rev 249452)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStandardLibrary.txt	2019-09-04 03:30:21 UTC (rev 249453)
@@ -13693,6 +13693,207 @@
 native float Sample(TextureDepth2DArray<float>, sampler, float3 location, int2 offset);
 native float Sample(TextureDepthCube<float>, sampler, float3 location);
 
+/* Functions named SampleLevel */
+native uint SampleLevel(Texture2D<uint>, sampler, float2 location, float LOD);
+native uint SampleLevel(Texture2D<uint>, sampler, float2 location, float LOD, int2 offset);
+native uint SampleLevel(Texture2DArray<uint>, sampler, float3 location, float LOD);
+native uint SampleLevel(Texture2DArray<uint>, sampler, float3 location, float LOD, int2 offset);
+native uint SampleLevel(TextureCube<uint>, sampler, float3 location, float LOD);
+native uint2 SampleLevel(Texture2D<uint2>, sampler, float2 location, float LOD);
+native uint2 SampleLevel(Texture2D<uint2>, sampler, float2 location, float LOD, int2 offset);
+native uint2 SampleLevel(Texture2DArray<uint2>, sampler, float3 location, float LOD);
+native uint2 SampleLevel(Texture2DArray<uint2>, sampler, float3 location, float LOD, int2 offset);
+native uint2 SampleLevel(TextureCube<uint2>, sampler, float3 location, float LOD);
+native uint3 SampleLevel(Texture2D<uint3>, sampler, float2 location, float LOD);
+native uint3 SampleLevel(Texture2D<uint3>, sampler, float2 location, float LOD, int2 offset);
+native uint3 SampleLevel(Texture2DArray<uint3>, sampler, float3 location, float LOD);
+native uint3 SampleLevel(Texture2DArray<uint3>, sampler, float3 location, float LOD, int2 offset);
+native uint3 SampleLevel(TextureCube<uint3>, sampler, float3 location, float LOD);
+native uint4 SampleLevel(Texture2D<uint4>, sampler, float2 location, float LOD);
+native uint4 SampleLevel(Texture2D<uint4>, sampler, float2 location, float LOD, int2 offset);
+native uint4 SampleLevel(Texture2DArray<uint4>, sampler, float3 location, float LOD);
+native uint4 SampleLevel(Texture2DArray<uint4>, sampler, float3 location, float LOD, int2 offset);
+native uint4 SampleLevel(TextureCube<uint4>, sampler, float3 location, float LOD);
+native int SampleLevel(Texture2D<int>, sampler, float2 location, float LOD);
+native int SampleLevel(Texture2D<int>, sampler, float2 location, float LOD, int2 offset);
+native int SampleLevel(Texture2DArray<int>, sampler, float3 location, float LOD);
+native int SampleLevel(Texture2DArray<int>, sampler, float3 location, float LOD, int2 offset);
+native int SampleLevel(TextureCube<int>, sampler, float3 location, float LOD);
+native int2 SampleLevel(Texture2D<int2>, sampler, float2 location, float LOD);
+native int2 SampleLevel(Texture2D<int2>, sampler, float2 location, float LOD, int2 offset);
+native int2 SampleLevel(Texture2DArray<int2>, sampler, float3 location, float LOD);
+native int2 SampleLevel(Texture2DArray<int2>, sampler, float3 location, float LOD, int2 offset);
+native int2 SampleLevel(TextureCube<int2>, sampler, float3 location, float LOD);
+native int3 SampleLevel(Texture2D<int3>, sampler, float2 location, float LOD);
+native int3 SampleLevel(Texture2D<int3>, sampler, float2 location, float LOD, int2 offset);
+native int3 SampleLevel(Texture2DArray<int3>, sampler, float3 location, float LOD);
+native int3 SampleLevel(Texture2DArray<int3>, sampler, float3 location, float LOD, int2 offset);
+native int3 SampleLevel(TextureCube<int3>, sampler, float3 location, float LOD);
+native int4 SampleLevel(Texture2D<int4>, sampler, float2 location, float LOD);
+native int4 SampleLevel(Texture2D<int4>, sampler, float2 location, float LOD, int2 offset);
+native int4 SampleLevel(Texture2DArray<int4>, sampler, float3 location, float LOD);
+native int4 SampleLevel(Texture2DArray<int4>, sampler, float3 location, float LOD, int2 offset);
+native int4 SampleLevel(TextureCube<int4>, sampler, float3 location, float LOD);
+native float SampleLevel(Texture2D<float>, sampler, float2 location, float LOD);
+native float SampleLevel(Texture2D<float>, sampler, float2 location, float LOD, int2 offset);
+native float SampleLevel(Texture2DArray<float>, sampler, float3 location, float LOD);
+native float SampleLevel(Texture2DArray<float>, sampler, float3 location, float LOD, int2 offset);
+native float SampleLevel(TextureCube<float>, sampler, float3 location, float LOD);
+native float2 SampleLevel(Texture2D<float2>, sampler, float2 location, float LOD);
+native float2 SampleLevel(Texture2D<float2>, sampler, float2 location, float LOD, int2 offset);
+native float2 SampleLevel(Texture2DArray<float2>, sampler, float3 location, float LOD);
+native float2 SampleLevel(Texture2DArray<float2>, sampler, float3 location, float LOD, int2 offset);
+native float2 SampleLevel(TextureCube<float2>, sampler, float3 location, float LOD);
+native float3 SampleLevel(Texture2D<float3>, sampler, float2 location, float LOD);
+native float3 SampleLevel(Texture2D<float3>, sampler, float2 location, float LOD, int2 offset);
+native float3 SampleLevel(Texture2DArray<float3>, sampler, float3 location, float LOD);
+native float3 SampleLevel(Texture2DArray<float3>, sampler, float3 location, float LOD, int2 offset);
+native float3 SampleLevel(TextureCube<float3>, sampler, float3 location, float LOD);
+native float4 SampleLevel(Texture2D<float4>, sampler, float2 location, float LOD);
+native float4 SampleLevel(Texture2D<float4>, sampler, float2 location, float LOD, int2 offset);
+native float4 SampleLevel(Texture2DArray<float4>, sampler, float3 location, float LOD);
+native float4 SampleLevel(Texture2DArray<float4>, sampler, float3 location, float LOD, int2 offset);
+native float4 SampleLevel(TextureCube<float4>, sampler, float3 location, float LOD);
+native float SampleLevel(TextureDepth2D<float>, sampler, float2 location, float LOD);
+native float SampleLevel(TextureDepth2D<float>, sampler, float2 location, float LOD, int2 offset);
+native float SampleLevel(TextureDepth2DArray<float>, sampler, float3 location, float LOD);
+native float SampleLevel(TextureDepth2DArray<float>, sampler, float3 location, float LOD, int2 offset);
+native float SampleLevel(TextureDepthCube<float>, sampler, float3 location, float LOD);
+
+/* Functions named SampleBias */
+native uint SampleBias(Texture2D<uint>, sampler, float2 location, float Bias);
+native uint SampleBias(Texture2D<uint>, sampler, float2 location, float Bias, int2 offset);
+native uint SampleBias(Texture2DArray<uint>, sampler, float3 location, float Bias);
+native uint SampleBias(Texture2DArray<uint>, sampler, float3 location, float Bias, int2 offset);
+native uint SampleBias(TextureCube<uint>, sampler, float3 location, float Bias);
+native uint2 SampleBias(Texture2D<uint2>, sampler, float2 location, float Bias);
+native uint2 SampleBias(Texture2D<uint2>, sampler, float2 location, float Bias, int2 offset);
+native uint2 SampleBias(Texture2DArray<uint2>, sampler, float3 location, float Bias);
+native uint2 SampleBias(Texture2DArray<uint2>, sampler, float3 location, float Bias, int2 offset);
+native uint2 SampleBias(TextureCube<uint2>, sampler, float3 location, float Bias);
+native uint3 SampleBias(Texture2D<uint3>, sampler, float2 location, float Bias);
+native uint3 SampleBias(Texture2D<uint3>, sampler, float2 location, float Bias, int2 offset);
+native uint3 SampleBias(Texture2DArray<uint3>, sampler, float3 location, float Bias);
+native uint3 SampleBias(Texture2DArray<uint3>, sampler, float3 location, float Bias, int2 offset);
+native uint3 SampleBias(TextureCube<uint3>, sampler, float3 location, float Bias);
+native uint4 SampleBias(Texture2D<uint4>, sampler, float2 location, float Bias);
+native uint4 SampleBias(Texture2D<uint4>, sampler, float2 location, float Bias, int2 offset);
+native uint4 SampleBias(Texture2DArray<uint4>, sampler, float3 location, float Bias);
+native uint4 SampleBias(Texture2DArray<uint4>, sampler, float3 location, float Bias, int2 offset);
+native uint4 SampleBias(TextureCube<uint4>, sampler, float3 location, float Bias);
+native int SampleBias(Texture2D<int>, sampler, float2 location, float Bias);
+native int SampleBias(Texture2D<int>, sampler, float2 location, float Bias, int2 offset);
+native int SampleBias(Texture2DArray<int>, sampler, float3 location, float Bias);
+native int SampleBias(Texture2DArray<int>, sampler, float3 location, float Bias, int2 offset);
+native int SampleBias(TextureCube<int>, sampler, float3 location, float Bias);
+native int2 SampleBias(Texture2D<int2>, sampler, float2 location, float Bias);
+native int2 SampleBias(Texture2D<int2>, sampler, float2 location, float Bias, int2 offset);
+native int2 SampleBias(Texture2DArray<int2>, sampler, float3 location, float Bias);
+native int2 SampleBias(Texture2DArray<int2>, sampler, float3 location, float Bias, int2 offset);
+native int2 SampleBias(TextureCube<int2>, sampler, float3 location, float Bias);
+native int3 SampleBias(Texture2D<int3>, sampler, float2 location, float Bias);
+native int3 SampleBias(Texture2D<int3>, sampler, float2 location, float Bias, int2 offset);
+native int3 SampleBias(Texture2DArray<int3>, sampler, float3 location, float Bias);
+native int3 SampleBias(Texture2DArray<int3>, sampler, float3 location, float Bias, int2 offset);
+native int3 SampleBias(TextureCube<int3>, sampler, float3 location, float Bias);
+native int4 SampleBias(Texture2D<int4>, sampler, float2 location, float Bias);
+native int4 SampleBias(Texture2D<int4>, sampler, float2 location, float Bias, int2 offset);
+native int4 SampleBias(Texture2DArray<int4>, sampler, float3 location, float Bias);
+native int4 SampleBias(Texture2DArray<int4>, sampler, float3 location, float Bias, int2 offset);
+native int4 SampleBias(TextureCube<int4>, sampler, float3 location, float Bias);
+native float SampleBias(Texture2D<float>, sampler, float2 location, float Bias);
+native float SampleBias(Texture2D<float>, sampler, float2 location, float Bias, int2 offset);
+native float SampleBias(Texture2DArray<float>, sampler, float3 location, float Bias);
+native float SampleBias(Texture2DArray<float>, sampler, float3 location, float Bias, int2 offset);
+native float SampleBias(TextureCube<float>, sampler, float3 location, float Bias);
+native float2 SampleBias(Texture2D<float2>, sampler, float2 location, float Bias);
+native float2 SampleBias(Texture2D<float2>, sampler, float2 location, float Bias, int2 offset);
+native float2 SampleBias(Texture2DArray<float2>, sampler, float3 location, float Bias);
+native float2 SampleBias(Texture2DArray<float2>, sampler, float3 location, float Bias, int2 offset);
+native float2 SampleBias(TextureCube<float2>, sampler, float3 location, float Bias);
+native float3 SampleBias(Texture2D<float3>, sampler, float2 location, float Bias);
+native float3 SampleBias(Texture2D<float3>, sampler, float2 location, float Bias, int2 offset);
+native float3 SampleBias(Texture2DArray<float3>, sampler, float3 location, float Bias);
+native float3 SampleBias(Texture2DArray<float3>, sampler, float3 location, float Bias, int2 offset);
+native float3 SampleBias(TextureCube<float3>, sampler, float3 location, float Bias);
+native float4 SampleBias(Texture2D<float4>, sampler, float2 location, float Bias);
+native float4 SampleBias(Texture2D<float4>, sampler, float2 location, float Bias, int2 offset);
+native float4 SampleBias(Texture2DArray<float4>, sampler, float3 location, float Bias);
+native float4 SampleBias(Texture2DArray<float4>, sampler, float3 location, float Bias, int2 offset);
+native float4 SampleBias(TextureCube<float4>, sampler, float3 location, float Bias);
+native float SampleBias(TextureDepth2D<float>, sampler, float2 location, float Bias);
+native float SampleBias(TextureDepth2D<float>, sampler, float2 location, float Bias, int2 offset);
+native float SampleBias(TextureDepth2DArray<float>, sampler, float3 location, float Bias);
+native float SampleBias(TextureDepth2DArray<float>, sampler, float3 location, float Bias, int2 offset);
+native float SampleBias(TextureDepthCube<float>, sampler, float3 location, float Bias);
+
+/* Functions named SampleGrad */
+native uint SampleGrad(Texture2D<uint>, sampler, float2 location, float2 DDX, float2 DDY);
+native uint SampleGrad(Texture2D<uint>, sampler, float2 location, float2 DDX, float2 DDY, int2 offset);
+native uint SampleGrad(Texture2DArray<uint>, sampler, float3 location, float2 DDX, float2 DDY);
+native uint SampleGrad(Texture2DArray<uint>, sampler, float3 location, float2 DDX, float2 DDY, int2 offset);
+native uint SampleGrad(TextureCube<uint>, sampler, float3 location, float3 DDX, float3 DDY);
+native uint2 SampleGrad(Texture2D<uint2>, sampler, float2 location, float2 DDX, float2 DDY);
+native uint2 SampleGrad(Texture2D<uint2>, sampler, float2 location, float2 DDX, float2 DDY, int2 offset);
+native uint2 SampleGrad(Texture2DArray<uint2>, sampler, float3 location, float2 DDX, float2 DDY);
+native uint2 SampleGrad(Texture2DArray<uint2>, sampler, float3 location, float2 DDX, float2 DDY, int2 offset);
+native uint2 SampleGrad(TextureCube<uint2>, sampler, float3 location, float3 DDX, float3 DDY);
+native uint3 SampleGrad(Texture2D<uint3>, sampler, float2 location, float2 DDX, float2 DDY);
+native uint3 SampleGrad(Texture2D<uint3>, sampler, float2 location, float2 DDX, float2 DDY, int2 offset);
+native uint3 SampleGrad(Texture2DArray<uint3>, sampler, float3 location, float2 DDX, float2 DDY);
+native uint3 SampleGrad(Texture2DArray<uint3>, sampler, float3 location, float2 DDX, float2 DDY, int2 offset);
+native uint3 SampleGrad(TextureCube<uint3>, sampler, float3 location, float3 DDX, float3 DDY);
+native uint4 SampleGrad(Texture2D<uint4>, sampler, float2 location, float2 DDX, float2 DDY);
+native uint4 SampleGrad(Texture2D<uint4>, sampler, float2 location, float2 DDX, float2 DDY, int2 offset);
+native uint4 SampleGrad(Texture2DArray<uint4>, sampler, float3 location, float2 DDX, float2 DDY);
+native uint4 SampleGrad(Texture2DArray<uint4>, sampler, float3 location, float2 DDX, float2 DDY, int2 offset);
+native uint4 SampleGrad(TextureCube<uint4>, sampler, float3 location, float3 DDX, float3 DDY);
+native int SampleGrad(Texture2D<int>, sampler, float2 location, float2 DDX, float2 DDY);
+native int SampleGrad(Texture2D<int>, sampler, float2 location, float2 DDX, float2 DDY, int2 offset);
+native int SampleGrad(Texture2DArray<int>, sampler, float3 location, float2 DDX, float2 DDY);
+native int SampleGrad(Texture2DArray<int>, sampler, float3 location, float2 DDX, float2 DDY, int2 offset);
+native int SampleGrad(TextureCube<int>, sampler, float3 location, float3 DDX, float3 DDY);
+native int2 SampleGrad(Texture2D<int2>, sampler, float2 location, float2 DDX, float2 DDY);
+native int2 SampleGrad(Texture2D<int2>, sampler, float2 location, float2 DDX, float2 DDY, int2 offset);
+native int2 SampleGrad(Texture2DArray<int2>, sampler, float3 location, float2 DDX, float2 DDY);
+native int2 SampleGrad(Texture2DArray<int2>, sampler, float3 location, float2 DDX, float2 DDY, int2 offset);
+native int2 SampleGrad(TextureCube<int2>, sampler, float3 location, float3 DDX, float3 DDY);
+native int3 SampleGrad(Texture2D<int3>, sampler, float2 location, float2 DDX, float2 DDY);
+native int3 SampleGrad(Texture2D<int3>, sampler, float2 location, float2 DDX, float2 DDY, int2 offset);
+native int3 SampleGrad(Texture2DArray<int3>, sampler, float3 location, float2 DDX, float2 DDY);
+native int3 SampleGrad(Texture2DArray<int3>, sampler, float3 location, float2 DDX, float2 DDY, int2 offset);
+native int3 SampleGrad(TextureCube<int3>, sampler, float3 location, float3 DDX, float3 DDY);
+native int4 SampleGrad(Texture2D<int4>, sampler, float2 location, float2 DDX, float2 DDY);
+native int4 SampleGrad(Texture2D<int4>, sampler, float2 location, float2 DDX, float2 DDY, int2 offset);
+native int4 SampleGrad(Texture2DArray<int4>, sampler, float3 location, float2 DDX, float2 DDY);
+native int4 SampleGrad(Texture2DArray<int4>, sampler, float3 location, float2 DDX, float2 DDY, int2 offset);
+native int4 SampleGrad(TextureCube<int4>, sampler, float3 location, float3 DDX, float3 DDY);
+native float SampleGrad(Texture2D<float>, sampler, float2 location, float2 DDX, float2 DDY);
+native float SampleGrad(Texture2D<float>, sampler, float2 location, float2 DDX, float2 DDY, int2 offset);
+native float SampleGrad(Texture2DArray<float>, sampler, float3 location, float2 DDX, float2 DDY);
+native float SampleGrad(Texture2DArray<float>, sampler, float3 location, float2 DDX, float2 DDY, int2 offset);
+native float SampleGrad(TextureCube<float>, sampler, float3 location, float3 DDX, float3 DDY);
+native float2 SampleGrad(Texture2D<float2>, sampler, float2 location, float2 DDX, float2 DDY);
+native float2 SampleGrad(Texture2D<float2>, sampler, float2 location, float2 DDX, float2 DDY, int2 offset);
+native float2 SampleGrad(Texture2DArray<float2>, sampler, float3 location, float2 DDX, float2 DDY);
+native float2 SampleGrad(Texture2DArray<float2>, sampler, float3 location, float2 DDX, float2 DDY, int2 offset);
+native float2 SampleGrad(TextureCube<float2>, sampler, float3 location, float3 DDX, float3 DDY);
+native float3 SampleGrad(Texture2D<float3>, sampler, float2 location, float2 DDX, float2 DDY);
+native float3 SampleGrad(Texture2D<float3>, sampler, float2 location, float2 DDX, float2 DDY, int2 offset);
+native float3 SampleGrad(Texture2DArray<float3>, sampler, float3 location, float2 DDX, float2 DDY);
+native float3 SampleGrad(Texture2DArray<float3>, sampler, float3 location, float2 DDX, float2 DDY, int2 offset);
+native float3 SampleGrad(TextureCube<float3>, sampler, float3 location, float3 DDX, float3 DDY);
+native float4 SampleGrad(Texture2D<float4>, sampler, float2 location, float2 DDX, float2 DDY);
+native float4 SampleGrad(Texture2D<float4>, sampler, float2 location, float2 DDX, float2 DDY, int2 offset);
+native float4 SampleGrad(Texture2DArray<float4>, sampler, float3 location, float2 DDX, float2 DDY);
+native float4 SampleGrad(Texture2DArray<float4>, sampler, float3 location, float2 DDX, float2 DDY, int2 offset);
+native float4 SampleGrad(TextureCube<float4>, sampler, float3 location, float3 DDX, float3 DDY);
+native float SampleGrad(TextureDepth2D<float>, sampler, float2 location, float2 DDX, float2 DDY);
+native float SampleGrad(TextureDepth2D<float>, sampler, float2 location, float2 DDX, float2 DDY, int2 offset);
+native float SampleGrad(TextureDepth2DArray<float>, sampler, float3 location, float2 DDX, float2 DDY);
+native float SampleGrad(TextureDepth2DArray<float>, sampler, float3 location, float2 DDX, float2 DDY, int2 offset);
+native float SampleGrad(TextureDepthCube<float>, sampler, float3 location, float3 DDX, float3 DDY);
+
 /* Functions named sinh */
 native float sinh(float);
 float2 sinh(float2 x) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to