From 2c2294d3310b24fd73cd41ec51338a736f3a2886 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 5 Sep 2023 23:26:59 +0800 Subject: SPIR-V image operations (#3163) * Add __truncate and __sampledType for spirv_asm Allows some texture tests to start passing * add __isVector Currently unused * Add 1-vector legalization pass (WIP) * Add capabilities for image types * neaten instruction dumping * add 1-vector test * Add a couple of cases to vec1 legalization * Remove texture tests from expected failures * comment * regenerate vs projects * Remove redundant define form synchapi emulation * refactoring image methods * All sample functions refactored * Remove incorrect glsl intrinsics Partially addresses https://github.com/shader-slang/slang/issues/3174 * __subscript image ops via writing funcs * Extract texture struct writing from core.meta.slang * Abstract out cuda intrinsic * Remvoe erroneous call to opDecorateIndex * spirv asm IR utils * Correct position of loads for SPIR-V asm inst operands * Raise constructors to global scope during spir-v legalization * Correct snippet output * Implement most texture sampling ops for SPIR-V * Legalize 1-vectors for glsl too * Make SPIR-V inst operands non-hoistable * Better 1-vector legalization * Put textures in ptrs for spirv * insert missing break * Add vec1 legalization test * Add some missing pieces to slang-ir-insts * Greatly neaten vec1 legalization * a * Neaten vec1 legalization * Add image read and write intrinsics for spir-v * Squash warnings * regenerate vs projects * Drop redundant guards * Drop 5 tests from expected failure list * Inst numbering changes to cross compile tests * vec1 legalization tests only on vk * Correct location of asm op emit * Inline constant in spirv-asm * Correct signedness for lane in wave intrinsics * Extract element from float1 for cuda * squash warnings * Neaten spirv-emit * dedupe more capabilities * warnings * neaten assert * comments * comments --- tests/cross-compile/non-uniform-indexing.slang.glsl | 16 +++++----------- tests/cross-compile/vk-texture-indexing.slang.glsl | 16 ++++------------ 2 files changed, 9 insertions(+), 23 deletions(-) (limited to 'tests/cross-compile') diff --git a/tests/cross-compile/non-uniform-indexing.slang.glsl b/tests/cross-compile/non-uniform-indexing.slang.glsl index 96abe6bac..07e8f9e38 100644 --- a/tests/cross-compile/non-uniform-indexing.slang.glsl +++ b/tests/cross-compile/non-uniform-indexing.slang.glsl @@ -1,10 +1,9 @@ -//TEST_IGNORE_FILE #version 450 - #extension GL_EXT_nonuniform_qualifier : require - +layout(row_major) uniform; +layout(row_major) buffer; layout(binding = 0) -uniform texture2D t_0[10]; +uniform texture2D t_0[10]; layout(binding = 1) uniform sampler s_0; @@ -17,12 +16,7 @@ in vec3 _S2; void main() { - vec4 _S3 = texture( - sampler2D( - t_0[nonuniformEXT(int(_S2.z))], - s_0), - _S2.xy); - - _S1 = _S3; + _S1 = (texture(sampler2D(t_0[nonuniformEXT(int(_S2.z))],s_0), (_S2.xy))); return; } + diff --git a/tests/cross-compile/vk-texture-indexing.slang.glsl b/tests/cross-compile/vk-texture-indexing.slang.glsl index 73513c623..7fd768465 100644 --- a/tests/cross-compile/vk-texture-indexing.slang.glsl +++ b/tests/cross-compile/vk-texture-indexing.slang.glsl @@ -3,31 +3,23 @@ #extension GL_EXT_nonuniform_qualifier : require layout(row_major) uniform; layout(row_major) buffer; - layout(binding = 0) uniform texture2D gParams_textures_0[10]; - float fetchData_0(uvec2 coords_0, uint index_0) { - float _S1 = (texelFetch((gParams_textures_0[nonuniformEXT(index_0)]), ivec2((coords_0)), 0).x); - - return _S1; + return (texelFetch((gParams_textures_0[nonuniformEXT(index_0)]), ivec2((coords_0)), 0).x); } layout(location = 0) -out vec4 _S2; - +out vec4 _S1; flat layout(location = 0) -in uvec3 _S3; - +in uvec3 _S2; void main() { - - _S2 = vec4(fetchData_0(_S3.xy, _S3.z)); - + _S1 = vec4(fetchData_0(_S2.xy, _S2.z)); return; } -- cgit v1.2.3