Skip to content

Commit

Permalink
Enable image bounds check snapshot tests for GLSL.
Browse files Browse the repository at this point in the history
In addition to the snapshot.rs changes, this entails adding an entry
point function to `bounds-check-image-restrict.wgsl` and
`bounds-check-image-rzsw.wgsl`, including appropriate data in the
param.ron files.
  • Loading branch information
jimblandy authored and JCapucho committed May 28, 2022
1 parent d6cc591 commit 009ed82
Show file tree
Hide file tree
Showing 11 changed files with 1,057 additions and 706 deletions.
5 changes: 5 additions & 0 deletions tests/in/bounds-check-image-restrict.param.ron
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
version: (1, 1),
debug: true,
),
glsl: (
version: Desktop(430),
writer_flags: (bits: 0),
binding_map: { },
),
)
43 changes: 32 additions & 11 deletions tests/in/bounds-check-image-restrict.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,79 +5,100 @@ fn test_textureLoad_1d(coords: i32, level: i32) -> vec4<f32> {
return textureLoad(image_1d, coords, level);
}

@group(0) @binding(0)
@group(0) @binding(1)
var image_2d: texture_2d<f32>;

fn test_textureLoad_2d(coords: vec2<i32>, level: i32) -> vec4<f32> {
return textureLoad(image_2d, coords, level);
}

@group(0) @binding(0)
@group(0) @binding(2)
var image_2d_array: texture_2d_array<f32>;

fn test_textureLoad_2d_array(coords: vec2<i32>, index: i32, level: i32) -> vec4<f32> {
return textureLoad(image_2d_array, coords, index, level);
}

@group(0) @binding(0)
@group(0) @binding(3)
var image_3d: texture_3d<f32>;

fn test_textureLoad_3d(coords: vec3<i32>, level: i32) -> vec4<f32> {
return textureLoad(image_3d, coords, level);
}

@group(0) @binding(0)
@group(0) @binding(4)
var image_multisampled_2d: texture_multisampled_2d<f32>;

fn test_textureLoad_multisampled_2d(coords: vec2<i32>, _sample: i32) -> vec4<f32> {
return textureLoad(image_multisampled_2d, coords, _sample);
}

@group(0) @binding(0)
@group(0) @binding(5)
var image_depth_2d: texture_depth_2d;

fn test_textureLoad_depth_2d(coords: vec2<i32>, level: i32) -> f32 {
return textureLoad(image_depth_2d, coords, level);
}

@group(0) @binding(0)
@group(0) @binding(6)
var image_depth_2d_array: texture_depth_2d_array;

fn test_textureLoad_depth_2d_array(coords: vec2<i32>, index: i32, level: i32) -> f32 {
return textureLoad(image_depth_2d_array, coords, index, level);
}

@group(0) @binding(0)
@group(0) @binding(7)
var image_depth_multisampled_2d: texture_depth_multisampled_2d;

fn test_textureLoad_depth_multisampled_2d(coords: vec2<i32>, _sample: i32) -> f32 {
return textureLoad(image_depth_multisampled_2d, coords, _sample);
}

@group(0) @binding(0)
@group(0) @binding(8)
var image_storage_1d: texture_storage_1d<rgba8unorm, write>;

fn test_textureStore_1d(coords: i32, value: vec4<f32>) {
textureStore(image_storage_1d, coords, value);
}

@group(0) @binding(0)
@group(0) @binding(9)
var image_storage_2d: texture_storage_2d<rgba8unorm, write>;

fn test_textureStore_2d(coords: vec2<i32>, value: vec4<f32>) {
textureStore(image_storage_2d, coords, value);
}

@group(0) @binding(0)
@group(0) @binding(10)
var image_storage_2d_array: texture_storage_2d_array<rgba8unorm, write>;

fn test_textureStore_2d_array(coords: vec2<i32>, array_index: i32, value: vec4<f32>) {
textureStore(image_storage_2d_array, coords, array_index, value);
}

@group(0) @binding(0)
@group(0) @binding(11)
var image_storage_3d: texture_storage_3d<rgba8unorm, write>;

fn test_textureStore_3d(coords: vec3<i32>, value: vec4<f32>) {
textureStore(image_storage_3d, coords, value);
}

// GLSL output requires that we identify an entry point, so
// that it can tell what "in" and "out" globals to write.
@fragment
fn fragment_shader() -> @location(0) vec4<f32> {
test_textureLoad_1d(0, 0);
test_textureLoad_2d(vec2<i32>(), 0);
test_textureLoad_2d_array(vec2<i32>(), 0, 0);
test_textureLoad_3d(vec3<i32>(), 0);
test_textureLoad_multisampled_2d(vec2<i32>(), 0);
// Not yet implemented for GLSL:
// test_textureLoad_depth_2d(vec2<i32>(), 0);
// test_textureLoad_depth_2d_array(vec2<i32>(), 0, 0);
// test_textureLoad_depth_multisampled_2d(vec2<i32>(), 0);
test_textureStore_1d(0, vec4<f32>());
test_textureStore_2d(vec2<i32>(), vec4<f32>());
test_textureStore_2d_array(vec2<i32>(), 0, vec4<f32>());
test_textureStore_3d(vec3<i32>(), vec4<f32>());

return vec4<f32>(0.,0.,0.,0.);
}
5 changes: 5 additions & 0 deletions tests/in/bounds-check-image-rzsw.param.ron
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
version: (1, 1),
debug: true,
),
glsl: (
version: Desktop(430),
writer_flags: (bits: 0),
binding_map: { },
),
)
43 changes: 32 additions & 11 deletions tests/in/bounds-check-image-rzsw.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,79 +5,100 @@ fn test_textureLoad_1d(coords: i32, level: i32) -> vec4<f32> {
return textureLoad(image_1d, coords, level);
}

@group(0) @binding(0)
@group(0) @binding(1)
var image_2d: texture_2d<f32>;

fn test_textureLoad_2d(coords: vec2<i32>, level: i32) -> vec4<f32> {
return textureLoad(image_2d, coords, level);
}

@group(0) @binding(0)
@group(0) @binding(2)
var image_2d_array: texture_2d_array<f32>;

fn test_textureLoad_2d_array(coords: vec2<i32>, index: i32, level: i32) -> vec4<f32> {
return textureLoad(image_2d_array, coords, index, level);
}

@group(0) @binding(0)
@group(0) @binding(3)
var image_3d: texture_3d<f32>;

fn test_textureLoad_3d(coords: vec3<i32>, level: i32) -> vec4<f32> {
return textureLoad(image_3d, coords, level);
}

@group(0) @binding(0)
@group(0) @binding(4)
var image_multisampled_2d: texture_multisampled_2d<f32>;

fn test_textureLoad_multisampled_2d(coords: vec2<i32>, _sample: i32) -> vec4<f32> {
return textureLoad(image_multisampled_2d, coords, _sample);
}

@group(0) @binding(0)
@group(0) @binding(5)
var image_depth_2d: texture_depth_2d;

fn test_textureLoad_depth_2d(coords: vec2<i32>, level: i32) -> f32 {
return textureLoad(image_depth_2d, coords, level);
}

@group(0) @binding(0)
@group(0) @binding(6)
var image_depth_2d_array: texture_depth_2d_array;

fn test_textureLoad_depth_2d_array(coords: vec2<i32>, index: i32, level: i32) -> f32 {
return textureLoad(image_depth_2d_array, coords, index, level);
}

@group(0) @binding(0)
@group(0) @binding(7)
var image_depth_multisampled_2d: texture_depth_multisampled_2d;

fn test_textureLoad_depth_multisampled_2d(coords: vec2<i32>, _sample: i32) -> f32 {
return textureLoad(image_depth_multisampled_2d, coords, _sample);
}

@group(0) @binding(0)
@group(0) @binding(8)
var image_storage_1d: texture_storage_1d<rgba8unorm, write>;

fn test_textureStore_1d(coords: i32, value: vec4<f32>) {
textureStore(image_storage_1d, coords, value);
}

@group(0) @binding(0)
@group(0) @binding(9)
var image_storage_2d: texture_storage_2d<rgba8unorm, write>;

fn test_textureStore_2d(coords: vec2<i32>, value: vec4<f32>) {
textureStore(image_storage_2d, coords, value);
}

@group(0) @binding(0)
@group(0) @binding(10)
var image_storage_2d_array: texture_storage_2d_array<rgba8unorm, write>;

fn test_textureStore_2d_array(coords: vec2<i32>, array_index: i32, value: vec4<f32>) {
textureStore(image_storage_2d_array, coords, array_index, value);
}

@group(0) @binding(0)
@group(0) @binding(11)
var image_storage_3d: texture_storage_3d<rgba8unorm, write>;

fn test_textureStore_3d(coords: vec3<i32>, value: vec4<f32>) {
textureStore(image_storage_3d, coords, value);
}

// GLSL output requires that we identify an entry point, so
// that it can tell what "in" and "out" globals to write.
@fragment
fn fragment_shader() -> @location(0) vec4<f32> {
test_textureLoad_1d(0, 0);
test_textureLoad_2d(vec2<i32>(), 0);
test_textureLoad_2d_array(vec2<i32>(), 0, 0);
test_textureLoad_3d(vec3<i32>(), 0);
test_textureLoad_multisampled_2d(vec2<i32>(), 0);
// Not yet implemented for GLSL:
// test_textureLoad_depth_2d(vec2<i32>(), 0);
// test_textureLoad_depth_2d_array(vec2<i32>(), 0, 0);
// test_textureLoad_depth_multisampled_2d(vec2<i32>(), 0);
test_textureStore_1d(0, vec4<f32>());
test_textureStore_2d(vec2<i32>(), vec4<f32>());
test_textureStore_2d_array(vec2<i32>(), 0, vec4<f32>());
test_textureStore_3d(vec3<i32>(), vec4<f32>());

return vec4<f32>(0.,0.,0.,0.);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#version 430 core
#extension GL_ARB_shader_texture_image_samples : require
uniform highp sampler1D _group_0_binding_0_fs;

uniform highp sampler2D _group_0_binding_1_fs;

uniform highp sampler2DArray _group_0_binding_2_fs;

uniform highp sampler3D _group_0_binding_3_fs;

uniform highp sampler2DMS _group_0_binding_4_fs;

layout(rgba8ui) writeonly uniform highp image1D _group_0_binding_8_fs;

layout(rgba8ui) writeonly uniform highp image2D _group_0_binding_9_fs;

layout(rgba8ui) writeonly uniform highp image2DArray _group_0_binding_10_fs;

layout(rgba8ui) writeonly uniform highp image3D _group_0_binding_11_fs;

layout(location = 0) out vec4 _fs2p_location0;

vec4 test_textureLoad_1d(int coords, int level) {
int _e3_clamped_lod = clamp(level, 0, textureQueryLevels(_group_0_binding_0_fs) - 1);
vec4 _e3 = texelFetch(_group_0_binding_0_fs, clamp(coords, 0, textureSize(_group_0_binding_0_fs, _e3_clamped_lod) - 1), _e3_clamped_lod);
return _e3;
}

vec4 test_textureLoad_2d(ivec2 coords_1, int level_1) {
int _e4_clamped_lod = clamp(level_1, 0, textureQueryLevels(_group_0_binding_1_fs) - 1);
vec4 _e4 = texelFetch(_group_0_binding_1_fs, clamp(coords_1, ivec2(0), textureSize(_group_0_binding_1_fs, _e4_clamped_lod) - ivec2(1)), _e4_clamped_lod);
return _e4;
}

vec4 test_textureLoad_2d_array(ivec2 coords_2, int index, int level_2) {
int _e6_clamped_lod = clamp(level_2, 0, textureQueryLevels(_group_0_binding_2_fs) - 1);
vec4 _e6 = texelFetch(_group_0_binding_2_fs, clamp(ivec3(coords_2, index), ivec3(0), textureSize(_group_0_binding_2_fs, _e6_clamped_lod) - ivec3(1)), _e6_clamped_lod);
return _e6;
}

vec4 test_textureLoad_3d(ivec3 coords_3, int level_3) {
int _e6_clamped_lod = clamp(level_3, 0, textureQueryLevels(_group_0_binding_3_fs) - 1);
vec4 _e6 = texelFetch(_group_0_binding_3_fs, clamp(coords_3, ivec3(0), textureSize(_group_0_binding_3_fs, _e6_clamped_lod) - ivec3(1)), _e6_clamped_lod);
return _e6;
}

vec4 test_textureLoad_multisampled_2d(ivec2 coords_4, int _sample) {
vec4 _e7 = texelFetch(_group_0_binding_4_fs, clamp(coords_4, ivec2(0), textureSize(_group_0_binding_4_fs) - ivec2(1)), clamp(_sample, 0, textureSamples(_group_0_binding_4_fs) - 1)
);
return _e7;
}

void test_textureStore_1d(int coords_8, vec4 value) {
imageStore(_group_0_binding_8_fs, coords_8, value);
return;
}

void test_textureStore_2d(ivec2 coords_9, vec4 value_1) {
imageStore(_group_0_binding_9_fs, coords_9, value_1);
return;
}

void test_textureStore_2d_array(ivec2 coords_10, int array_index, vec4 value_2) {
imageStore(_group_0_binding_10_fs, ivec3(coords_10, array_index), value_2);
return;
}

void test_textureStore_3d(ivec3 coords_11, vec4 value_3) {
imageStore(_group_0_binding_11_fs, coords_11, value_3);
return;
}

void main() {
vec4 _e14 = test_textureLoad_1d(0, 0);
vec4 _e17 = test_textureLoad_2d(ivec2(0, 0), 0);
vec4 _e21 = test_textureLoad_2d_array(ivec2(0, 0), 0, 0);
vec4 _e24 = test_textureLoad_3d(ivec3(0, 0, 0), 0);
vec4 _e27 = test_textureLoad_multisampled_2d(ivec2(0, 0), 0);
test_textureStore_1d(0, vec4(0.0, 0.0, 0.0, 0.0));
test_textureStore_2d(ivec2(0, 0), vec4(0.0, 0.0, 0.0, 0.0));
test_textureStore_2d_array(ivec2(0, 0), 0, vec4(0.0, 0.0, 0.0, 0.0));
test_textureStore_3d(ivec3(0, 0, 0), vec4(0.0, 0.0, 0.0, 0.0));
_fs2p_location0 = vec4(0.0, 0.0, 0.0, 0.0);
return;
}

Loading

0 comments on commit 009ed82

Please sign in to comment.