Source code
Revision control
Copy as Markdown
Other Tools
<!--
Copyright (c) 2019 The Khronos Group Inc.
Use of this source code is governed by an MIT-style license that can be
found in the LICENSE.txt file.
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>GLSL texture offset with non-constant offset test</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../js/js-test-pre.js"></script>
<script src="../../js/webgl-test-utils.js"></script>
<script src="../../js/glsl-conformance-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="fshaderTextureOffset" type="x-shader/x-fragment">#version 300 es
precision mediump float;
out vec4 my_FragColor;
uniform sampler2D u_sampler;
uniform vec2 u_texCoord;
void main() {
ivec2 offset = ivec2(0);
my_FragColor = textureOffset(u_sampler, u_texCoord, offset);
}
</script>
<script id="fshaderTextureProjOffset" type="x-shader/x-fragment">#version 300 es
precision mediump float;
out vec4 my_FragColor;
uniform sampler2D u_sampler;
uniform vec4 u_texCoord;
void main() {
ivec2 offset = ivec2(0);
my_FragColor = textureProjOffset(u_sampler, u_texCoord, offset);
}
</script>
<script id="fshaderTextureLodOffset" type="x-shader/x-fragment">#version 300 es
precision mediump float;
out vec4 my_FragColor;
uniform sampler2D u_sampler;
uniform vec2 u_texCoord;
uniform float u_lod;
void main() {
ivec2 offset = ivec2(0);
my_FragColor = textureLodOffset(u_sampler, u_texCoord, u_lod, offset);
}
</script>
<script id="fshaderTextureProjLodOffset" type="x-shader/x-fragment">#version 300 es
precision mediump float;
out vec4 my_FragColor;
uniform sampler2D u_sampler;
uniform vec4 u_texCoord;
uniform float u_lod;
void main() {
ivec2 offset = ivec2(0);
my_FragColor = textureProjLodOffset(u_sampler, u_texCoord, u_lod, offset);
}
</script>
<script id="fshaderTextureGradOffset" type="x-shader/x-fragment">#version 300 es
precision mediump float;
out vec4 my_FragColor;
uniform sampler2D u_sampler;
uniform vec2 u_texCoord;
uniform vec2 u_dPdx;
uniform vec2 u_dPdy;
void main() {
ivec2 offset = ivec2(0);
my_FragColor = textureGradOffset(u_sampler, u_texCoord, u_dPdx, u_dPdy, offset);
}
</script>
<script id="fshaderTextureProjGradOffset" type="x-shader/x-fragment">#version 300 es
precision mediump float;
out vec4 my_FragColor;
uniform sampler2D u_sampler;
uniform vec4 u_texCoord;
uniform vec2 u_dPdx;
uniform vec2 u_dPdy;
void main() {
ivec2 offset = ivec2(0);
my_FragColor = textureProjGradOffset(u_sampler, u_texCoord, u_dPdx, u_dPdy, offset);
}
</script>
<script id="fshaderTexelFetchOffset" type="x-shader/x-fragment">#version 300 es
precision mediump float;
out vec4 my_FragColor;
uniform sampler2D u_sampler;
uniform vec2 u_texCoord;
uniform vec2 u_lod;
void main() {
ivec2 offset = ivec2(0);
my_FragColor = texelFetchOffset(u_sampler, ivec2(u_texCoord), int(u_lod), offset);
}
</script>
<script type="application/javascript">
"use strict";
description("A non-constant offset is not valid in texture offset functions.");
var wtu = WebGLTestUtils;
var shaderTextureOffsetSrc = wtu.getScript('fshaderTextureOffset');
var shaderTextureLodOffsetSrc = wtu.getScript('fshaderTextureLodOffset');
var shaderTextureGradOffsetSrc = wtu.getScript('fshaderTextureGradOffset');
var shaderTextureProjOffsetSrc = wtu.getScript('fshaderTextureProjOffset');
var shaderTextureProjLodOffsetSrc = wtu.getScript('fshaderTextureProjLodOffset');
var shaderTextureProjGradOffsetSrc = wtu.getScript('fshaderTextureProjGradOffset');
var shaderTexelFetchOffsetSrc = wtu.getScript('fshaderTexelFetchOffset');
var gl = wtu.create3DContext(undefined, undefined, 2);
if (!gl) {
testFailed("Unable to initialize WebGL 2.0 context.");
} else {
GLSLConformanceTester.runTests([
{
fShaderSource: shaderTextureOffsetSrc,
fShaderSuccess: false,
passMsg: 'textureOffset with non-constant offset is invalid'
},
{
fShaderSource: shaderTextureLodOffsetSrc,
fShaderSuccess: false,
passMsg: 'textureLodOffset with non-constant offset is invalid'
},
{
fShaderSource: shaderTextureGradOffsetSrc,
fShaderSuccess: false,
passMsg: 'textureGradOffset with non-constant offset is invalid'
},
{
fShaderSource: shaderTextureProjOffsetSrc,
fShaderSuccess: false,
passMsg: 'textureProjOffset with non-constant offset is invalid'
},
{
fShaderSource: shaderTextureProjLodOffsetSrc,
fShaderSuccess: false,
passMsg: 'textureProjLodOffset with non-constant offset is invalid'
},
{
fShaderSource: shaderTextureProjGradOffsetSrc,
fShaderSuccess: false,
passMsg: 'textureProjGradOffset with non-constant offset is invalid'
},
{
fShaderSource: shaderTexelFetchOffsetSrc,
fShaderSuccess: false,
passMsg: 'texelFetchOffset with non-constant offset is invalid'
}
], 2);
}
</script>
</body>
</html>