diff options
| -rw-r--r-- | source/slang/core.meta.slang | 55 | ||||
| -rw-r--r-- | source/slang/hlsl.meta.slang | 21 | ||||
| -rw-r--r-- | source/slang/slang-emit-c-like.cpp | 24 | ||||
| -rw-r--r-- | source/slang/slang-ir-redundancy-removal.cpp | 17 | ||||
| -rw-r--r-- | source/slang/slang-ir-util.cpp | 10 | ||||
| -rw-r--r-- | tests/autodiff/global-param-hoisting.slang | 42 | ||||
| -rw-r--r-- | tests/autodiff/global-param-hoisting.slang.expected.txt | 6 | ||||
| -rw-r--r-- | tests/bindings/glsl-parameter-blocks.slang.glsl | 51 | ||||
| -rw-r--r-- | tests/bindings/multiple-parameter-blocks.slang | 9 | ||||
| -rw-r--r-- | tests/bugs/texture2d-ms.hlsl | 4 | ||||
| -rw-r--r-- | tests/bugs/texture2d-ms.hlsl.glsl | 15 | ||||
| -rw-r--r-- | tests/cross-compile/array-of-buffers.slang.glsl | 10 | ||||
| -rw-r--r-- | tests/cross-compile/array-of-buffers.slang.hlsl | 10 |
13 files changed, 208 insertions, 66 deletions
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang index 9da33c755..2507c22dd 100644 --- a/source/slang/core.meta.slang +++ b/source/slang/core.meta.slang @@ -1189,6 +1189,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) continue; } + bool isReadOnly = (access == SLANG_RESOURCE_ACCESS_READ); // TODO: any constraints to enforce on what gets to be multisampled? unsigned flavor = baseShape; @@ -1318,6 +1319,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) char const* t = isFloat ? "out float " : "out uint "; + sb << "[__readNone]\n"; sb << "void GetDimensions("; if(includeMipInfo) sb << "uint mipLevel, "; @@ -1487,6 +1489,8 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) } } + if (isReadOnly) + sb << "[__readNone]\n"; sb << "T Load("; sb << "int" << loadCoordCount << " location"; if(isMultisample) @@ -1516,8 +1520,8 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) sb << ", $2)$z\")\n"; } - - + if (isReadOnly) + sb << "[__readNone]\n"; sb << "T Load("; sb << "int" << loadCoordCount << " location"; if(isMultisample) @@ -1527,7 +1531,8 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) sb << ", constexpr int" << kBaseTextureTypes[tt].coordCount << " offset"; sb << ");\n"; - + if (isReadOnly) + sb << "[__readNone]\n"; sb << "T Load("; sb << "int" << loadCoordCount << " location"; if(isMultisample) @@ -1632,6 +1637,8 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) } // Output that has get + if (isReadOnly) + sb << "[__readNone]\n"; sb << " get;\n"; // !!!!!!!!!!!!!!!!!!!! set !!!!!!!!!!!!!!!!!!!!!!! @@ -1747,17 +1754,23 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) } } + if (isReadOnly) + sb << "[__readNone]\n"; sb << "T Sample(" << samplerStateParam;; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location);\n"; if( baseShape != TextureFlavor::Shape::ShapeCube ) { sb << "__target_intrinsic(glsl, \"$ctextureOffset($p, $2, $3)$z\")\n"; + if (isReadOnly) + sb << "[__readNone]\n"; sb << "T Sample(" << samplerStateParam;; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, "; sb << "constexpr int" << kBaseTextureTypes[tt].coordCount << " offset);\n"; } + if (isReadOnly) + sb << "[__readNone]\n"; sb << "T Sample(" << samplerStateParam; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, "; if( baseShape != TextureFlavor::Shape::ShapeCube ) @@ -1766,6 +1779,8 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) } sb << "float clamp);\n"; + if (isReadOnly) + sb << "[__readNone]\n"; sb << "T Sample(" << samplerStateParam; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, "; if( baseShape != TextureFlavor::Shape::ShapeCube ) @@ -1776,12 +1791,16 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) // `SampleBias()` sb << "__target_intrinsic(glsl, \"$ctexture($p, $2, $3)$z\")\n"; + if (isReadOnly) + sb << "[__readNone]\n"; sb << "T SampleBias(" << samplerStateParam; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, float bias);\n"; if( baseShape != TextureFlavor::Shape::ShapeCube ) { sb << "__target_intrinsic(glsl, \"$ctextureOffset($p, $2, $3, $4)$z\")\n"; + if (isReadOnly) + sb << "[__readNone]\n"; sb << "T SampleBias(" << samplerStateParam; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, float bias, "; sb << "constexpr int" << kBaseTextureTypes[tt].coordCount << " offset);\n"; @@ -1792,11 +1811,15 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) { // `SampleCmp()` and `SampleCmpLevelZero` sb << "__target_intrinsic(glsl, \"texture($p, vec" << arrCoordCount + 1 << "($2, $3))\")"; + if (isReadOnly) + sb << "[__readNone]\n"; sb << "float SampleCmp(SamplerComparisonState s, "; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, "; sb << "float compareValue"; sb << ");\n"; sb << "__target_intrinsic(glsl, \"texture($p, vec" << arrCoordCount + 1 << "($2, $3))\")"; + if (isReadOnly) + sb << "[__readNone]\n"; sb << "float SampleCmpLevelZero(SamplerComparisonState s, "; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, "; sb << "float compareValue"; @@ -1851,12 +1874,15 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) // saying they only exclude `offset` for cube maps (which makes // sense). I'm going to assume the documentation for `SampleCmp` // is just wrong. - + if (isReadOnly) + sb << "[__readNone]\n"; sb << "float SampleCmp(SamplerComparisonState s, "; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, "; sb << "float compareValue, "; sb << "constexpr int" << kBaseTextureTypes[tt].coordCount << " offset);\n"; + if (isReadOnly) + sb << "[__readNone]\n"; sb << "float SampleCmpLevelZero(SamplerComparisonState s, "; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, "; sb << "float compareValue, "; @@ -1867,6 +1893,8 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) // the dimension. On CUDA there is texNDGrad, but it always just takes ddx, ddy. // I could just assume 0 for elements not supplied, and ignore z. For now will just leave sb << "__target_intrinsic(glsl, \"$ctextureGrad($p, $2, $3, $4)$z\")\n"; + if (isReadOnly) + sb << "[__readNone]\n"; sb << "T SampleGrad(" << samplerStateParam; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, "; sb << "float" << kBaseTextureTypes[tt].coordCount << " gradX, "; @@ -1876,6 +1904,8 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) if( baseShape != TextureFlavor::Shape::ShapeCube ) { sb << "__target_intrinsic(glsl, \"$ctextureGradOffset($p, $2, $3, $4, $5)$z\")\n"; + if (isReadOnly) + sb << "[__readNone]\n"; sb << "T SampleGrad(" << samplerStateParam; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, "; sb << "float" << kBaseTextureTypes[tt].coordCount << " gradX, "; @@ -1884,6 +1914,8 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) sb << "__glsl_extension(GL_ARB_sparse_texture_clamp)"; sb << "__target_intrinsic(glsl, \"$ctextureGradOffsetClampARB($p, $2, $3, $4, $5, $6)$z\")\n"; + if (isReadOnly) + sb << "[__readNone]\n"; sb << "T SampleGrad(" << samplerStateParam; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, "; sb << "float" << kBaseTextureTypes[tt].coordCount << " gradX, "; @@ -1939,7 +1971,8 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) sb << ", $3)\")\n"; } } - + if (isReadOnly) + sb << "[__readNone]\n"; sb << "T SampleLevel(" << samplerStateParam; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, "; sb << "float level);\n"; @@ -1947,6 +1980,8 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) if( baseShape != TextureFlavor::Shape::ShapeCube ) { sb << "__target_intrinsic(glsl, \"$ctextureLodOffset($p, $2, $3, $4)$z\")\n"; + if (isReadOnly) + sb << "[__readNone]\n"; sb << "T SampleLevel(" << samplerStateParam; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, "; sb << "float level, "; @@ -2026,21 +2061,29 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) // "It is based on the base type of DataType except when readMode is equal to cudaReadModeNormalizedFloat (see Texture Reference API), in which case it is always float4." sb << "__target_intrinsic(cuda, \"tex2Dgather<$T0>($0, ($2).x, ($2).y, " << componentIndex << ")\")\n"; } + if (isReadOnly) + sb << "[__readNone]\n"; sb << outputType << " Gather" << componentName << "(" << samplerStateParam; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location);\n"; + if (isReadOnly) + sb << "[__readNone]\n"; EMIT_LINE_DIRECTIVE(); sb << "__target_intrinsic(glsl, \"textureGatherOffset($p, $2, $3, " << componentIndex << ")\")\n"; sb << outputType << " Gather" << componentName << "(" << samplerStateParam; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, "; sb << "constexpr int" << kBaseTextureTypes[tt].coordCount << " offset);\n"; + if (isReadOnly) + sb << "[__readNone]\n"; EMIT_LINE_DIRECTIVE(); sb << outputType << " Gather" << componentName << "(" << samplerStateParam; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, "; sb << "constexpr int" << kBaseTextureTypes[tt].coordCount << " offset, "; sb << "out uint status);\n"; + if (isReadOnly) + sb << "[__readNone]\n"; EMIT_LINE_DIRECTIVE(); sb << "__target_intrinsic(glsl, \"textureGatherOffsets($p, $2, int" << kBaseTextureTypes[tt].coordCount << "[]($3, $4, $5, $6), " << componentIndex << ")\")\n"; sb << outputType << " Gather" << componentName << "(" << samplerStateParam; @@ -2050,6 +2093,8 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt) sb << "int" << kBaseTextureTypes[tt].coordCount << " offset3, "; sb << "int" << kBaseTextureTypes[tt].coordCount << " offset4);\n"; + if (isReadOnly) + sb << "[__readNone]\n"; EMIT_LINE_DIRECTIVE(); sb << outputType << " Gather" << componentName << "(" << samplerStateParam; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, "; diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 37cdc205e..0b7ca535b 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -19,29 +19,39 @@ __intrinsic_type($(kIROp_HLSLByteAddressBufferType)) struct ByteAddressBuffer { __target_intrinsic(glsl, "$1 = $0._data.length() * 4") + [__readNone] void GetDimensions( out uint dim); __target_intrinsic(glsl, "$0._data[$1/4]") + [__readNone] uint Load(int location); + [__readNone] uint Load(int location, out uint status); __target_intrinsic(glsl, "uvec2($0._data[$1/4], $0._data[$1/4+1])") + [__readNone] uint2 Load2(int location); + [__readNone] uint2 Load2(int location, out uint status); __target_intrinsic(glsl, "uvec3($0._data[$1/4], $0._data[$1/4+1], $0._data[$1/4+2])") + [__readNone] uint3 Load3(int location); + [__readNone] uint3 Load3(int location, out uint status); __target_intrinsic(glsl, "uvec4($0._data[$1/4], $0._data[$1/4+1], $0._data[$1/4+2], $0._data[$1/4+3])") + [__readNone] uint4 Load4(int location); + [__readNone] uint4 Load4(int location, out uint status); + [__readNone] T Load<T>(int location) { return __byteAddressBufferLoad<T>(this, location); @@ -216,19 +226,24 @@ __intrinsic_type($(kIROp_HLSLStructuredBufferType)) struct StructuredBuffer { __target_intrinsic(glsl, "$1 = $0._data.length(); $2 = 0") + [__readNone] void GetDimensions( out uint numStructs, out uint stride); __target_intrinsic(glsl, "$0._data[$1]") __target_intrinsic(spirv_direct, "%addr = OpAccessChain resultType*StorageBuffer resultId _0 const(int, 0) _1; OpLoad resultType resultId %addr;") + [__readNone] T Load(int location); + + [__readNone] T Load(int location, out uint status); __subscript(uint index) -> T { __target_intrinsic(glsl, "$0._data[$1]") __target_intrinsic(spirv_direct, "%addr = OpAccessChain resultType*StorageBuffer resultId _0 const(int, 0) _1; OpLoad resultType resultId %addr;") + [__readNone] get; }; }; @@ -4923,6 +4938,7 @@ static const int kBaseBufferAccessLevelCount = sizeof(kBaseBufferAccessLevels) / for (int aa = 0; aa < kBaseBufferAccessLevelCount; ++aa) { auto access = kBaseBufferAccessLevels[aa].access; + bool isReadOnly = (access == SLANG_RESOURCE_ACCESS_READ); auto flavor = TextureFlavor::create(TextureFlavor::Shape::ShapeBuffer, access).flavor; sb << "__generic<T>\n"; sb << "__magic_type(Texture," << int(flavor) << ")\n"; @@ -4930,19 +4946,22 @@ for (int aa = 0; aa < kBaseBufferAccessLevelCount; ++aa) sb << "struct "; sb << kBaseBufferAccessLevels[aa].name; sb << "Buffer {\n"; - + sb << "[__readNone]\n"; sb << "void GetDimensions(out uint dim);\n"; char const* glslLoadFuncName = (access == SLANG_RESOURCE_ACCESS_READ) ? "texelFetch" : "imageLoad"; sb << "__glsl_extension(GL_EXT_samplerless_texture_functions)"; sb << "__target_intrinsic(glsl, \"" << glslLoadFuncName << "($0, $1)$z\")\n"; + if (isReadOnly) sb << "[__readNone]\n"; sb << "T Load(int location);\n"; + if (isReadOnly) sb << "[__readNone]\n"; sb << "T Load(int location, out uint status);\n"; sb << "__subscript(uint index) -> T {\n"; + if (isReadOnly) sb << "[__readNone]\n"; sb << "__glsl_extension(GL_EXT_samplerless_texture_functions)"; sb << "__target_intrinsic(glsl, \"" << glslLoadFuncName << "($0, int($1))$z\") get;\n"; diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp index 7840dc450..a31c16505 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -1344,6 +1344,30 @@ bool CLikeSourceEmitter::shouldFoldInstIntoUseSites(IRInst* inst) } } + // If this is a call to a ResourceType's member function, don't fold for readability. + if (auto call = as<IRCall>(inst)) + { + auto callee = getResolvedInstForDecorations(call->getCallee()); + if (callee->findDecoration<IRTargetIntrinsicDecoration>()) + { + auto funcType = as<IRFuncType>(callee->getDataType()); + if (funcType) + { + if (funcType->getParamCount() > 0) + { + auto firstParamType = funcType->getParamType(0); + if (as<IRResourceTypeBase>(firstParamType)) + return false; + if (as<IRHLSLStructuredBufferTypeBase>(firstParamType)) + return false; + if (as<IRUntypedBufferResourceType>(firstParamType)) + return false; + if (as<IRSamplerStateTypeBase>(firstParamType)) + return false; + } + } + } + } // We'd like to figure out if it is safe to fold our instruction into `user` // First, let's make sure they are in the same block/parent: diff --git a/source/slang/slang-ir-redundancy-removal.cpp b/source/slang/slang-ir-redundancy-removal.cpp index 2a2047de9..32b349a4f 100644 --- a/source/slang/slang-ir-redundancy-removal.cpp +++ b/source/slang/slang-ir-redundancy-removal.cpp @@ -28,6 +28,8 @@ struct RedundancyRemovalContext case kIROp_GetElement: case kIROp_GetElementPtr: case kIROp_UpdateElement: + case kIROp_Specialize: + case kIROp_LookupWitness: case kIROp_OptionalHasValue: case kIROp_GetOptionalValue: case kIROp_MakeOptionalValue: @@ -67,6 +69,21 @@ struct RedundancyRemovalContext return true; case kIROp_Call: return isPureFunctionalCall(as<IRCall>(inst)); + case kIROp_Load: + // Load is generally not movable, an exception is loading a global constant buffer. + if (auto load = as<IRLoad>(inst)) + { + auto addrType = load->getPtr()->getDataType(); + switch (addrType->getOp()) + { + case kIROp_ConstantBufferType: + case kIROp_ParameterBlockType: + return true; + default: + break; + } + } + return false; default: return false; } diff --git a/source/slang/slang-ir-util.cpp b/source/slang/slang-ir-util.cpp index 339521f41..13920b011 100644 --- a/source/slang/slang-ir-util.cpp +++ b/source/slang/slang-ir-util.cpp @@ -157,6 +157,7 @@ IRInst* maybeSpecializeWithGeneric(IRBuilder& builder, IRInst* genericToSpecaili return genericToSpecailize; } +// Returns true if is not possible to produce side-effect from a value of `dataType`. bool isValueType(IRInst* dataType) { dataType = getResolvedInstForDecorations(unwrapAttributedType(dataType)); @@ -179,6 +180,15 @@ bool isValueType(IRInst* dataType) case kIROp_FuncType: return true; default: + // Read-only resource handles are considered as Value type. + if (auto resType = as<IRResourceTypeBase>(dataType)) + return (resType->getAccess() == SLANG_RESOURCE_ACCESS_READ); + else if (as<IRSamplerStateTypeBase>(dataType)) + return true; + else if (as<IRHLSLByteAddressBufferType>(dataType)) + return true; + else if (as<IRHLSLStructuredBufferType>(dataType)) + return true; return false; } } diff --git a/tests/autodiff/global-param-hoisting.slang b/tests/autodiff/global-param-hoisting.slang new file mode 100644 index 000000000..72a9494fe --- /dev/null +++ b/tests/autodiff/global-param-hoisting.slang @@ -0,0 +1,42 @@ +// Test that the compiler can hoist the texture sample out of the loop. +// We currently have no way to verify the hoist actually take place, but this test +// allows us to manually inspect the generated code to see that happen. +// TODO: use a pattern checker on the resulting code to make sure there is only +// one call to `SampleLevel`. + +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type +//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -shaderobj + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<float> outputBuffer; + +struct Params : IDifferentiable +{ + Texture2D tex; + SamplerState sampler; +} + +//TEST_INPUT:set gParams = new Params{Texture2D(size=4, content=one), Sampler} +ParameterBlock<Params> gParams; + +[BackwardDifferentiable] +float f(float x) +{ + float sum = 0.0; + for (int i = 0; i < 3; i++) + { + float t = (no_diff gParams.tex.SampleLevel(gParams.sampler, float2(0.0), 0)).x; + sum += t * x * x; + } + return sum; +} + +[numthreads(1, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + var dpa = diffPair(3.0); + + __bwd_diff(f)(dpa, 1.0); + outputBuffer[0] = dpa.d.x; // Expect: 18 +} diff --git a/tests/autodiff/global-param-hoisting.slang.expected.txt b/tests/autodiff/global-param-hoisting.slang.expected.txt new file mode 100644 index 000000000..05d0a2ffd --- /dev/null +++ b/tests/autodiff/global-param-hoisting.slang.expected.txt @@ -0,0 +1,6 @@ +type: float +18.000000 +0.000000 +0.000000 +0.000000 +0.000000 diff --git a/tests/bindings/glsl-parameter-blocks.slang.glsl b/tests/bindings/glsl-parameter-blocks.slang.glsl index a27fbb3db..03e4e8774 100644 --- a/tests/bindings/glsl-parameter-blocks.slang.glsl +++ b/tests/bindings/glsl-parameter-blocks.slang.glsl @@ -1,52 +1,31 @@ -//TEST_IGNORE_FILE: -#version 450 core - -#define Test Test_0 -#define a a_0 - -#define gTest gTest_0 -#define gTest_t gTest_t_0 -#define gTest_s gTest_s_0 - -#define ParameterBlock_gTest _S1 - -#define main_result _S2 -#define uv _S3 - -#define temp_a _S4 -#define temp_sample _S5 -#define temp_add _S2 - -struct Test +#version 450 +layout(row_major) uniform; +layout(row_major) buffer; +struct Test_0 { - vec4 a; + vec4 a_0; }; layout(binding = 0) -uniform ParameterBlock_gTest +layout(std140) uniform _S1 { - Test _data; -} gTest; - + Test_0 _data; +} gTest_0; layout(binding = 1) -uniform texture2D gTest_t; +uniform texture2D gTest_t_0; layout(binding = 2) -uniform sampler gTest_s; +uniform sampler gTest_s_0; layout(location = 0) -out vec4 main_result; +out vec4 _S2; layout(location = 0) -in vec2 uv; +in vec2 _S3; void main() { - vec4 temp_a = gTest._data.a; - - vec4 temp_sample = texture(sampler2D(gTest_t, gTest_s), uv); - - main_result = temp_a + temp_sample; - - return; + vec4 _S4 = (texture(sampler2D(gTest_t_0,gTest_s_0), (_S3))); + _S2 = gTest_0._data.a_0 + _S4; + return; } diff --git a/tests/bindings/multiple-parameter-blocks.slang b/tests/bindings/multiple-parameter-blocks.slang index 29eea6766..0f247319d 100644 --- a/tests/bindings/multiple-parameter-blocks.slang +++ b/tests/bindings/multiple-parameter-blocks.slang @@ -39,10 +39,11 @@ SamplerState p1_s_0 : register(s0, space1); float4 main(float v : V) : SV_TARGET { - return use(p_t_0, p_s_0) - + use(p_ta_0[int(v)], p_s_0) - + use(p1_t_0, p1_s_0) - + use(p1_ta_0[int(v)], p1_s_0); + int _S2 = int(v); + return use(p_t_0, p_s_0) + + use(p_ta_0[_S2], p_s_0) + + use(p1_t_0, p1_s_0) + + use(p1_ta_0[_S2], p1_s_0); } #endif diff --git a/tests/bugs/texture2d-ms.hlsl b/tests/bugs/texture2d-ms.hlsl index 1d8293937..3fb84f72d 100644 --- a/tests/bugs/texture2d-ms.hlsl +++ b/tests/bugs/texture2d-ms.hlsl @@ -3,8 +3,10 @@ [[vk::binding(0, 0)]] Texture2DMS tex : register(t1); +RWStructuredBuffer<float4> outBuffer; + [numthreads(4, 4, 1)] void main(uint3 groupId : SV_GroupID) { - tex.Load(int2(groupId.xy), 0); + outBuffer[0] = tex.Load(int2(groupId.xy), 0); } diff --git a/tests/bugs/texture2d-ms.hlsl.glsl b/tests/bugs/texture2d-ms.hlsl.glsl index ba0d571dd..40ce5f9de 100644 --- a/tests/bugs/texture2d-ms.hlsl.glsl +++ b/tests/bugs/texture2d-ms.hlsl.glsl @@ -1,16 +1,17 @@ -// texture2d-ms.hlsl.glsl -//TEST_IGNORE_FILE: - #version 450 +#extension GL_EXT_samplerless_texture_functions : require layout(row_major) uniform; layout(row_major) buffer; -#extension GL_EXT_samplerless_texture_functions : require layout(binding = 0) uniform texture2DMS tex_0; -layout(local_size_x = 4, local_size_y = 4, local_size_z = 1) in;void main() +layout(std430, binding = 1) buffer _S1 { + vec4 _data[]; +} outBuffer_0; +layout(local_size_x = 4, local_size_y = 4, local_size_z = 1) in; +void main() { - vec4 _S1 = (texelFetch((tex_0), (ivec2(gl_WorkGroupID.xy)), (0))); + vec4 _S2 = (texelFetch((tex_0), (ivec2(gl_WorkGroupID.xy)), (0))); + ((outBuffer_0)._data[(0U)]) = _S2; return; } - diff --git a/tests/cross-compile/array-of-buffers.slang.glsl b/tests/cross-compile/array-of-buffers.slang.glsl index 21961afd1..4ff86f36e 100644 --- a/tests/cross-compile/array-of-buffers.slang.glsl +++ b/tests/cross-compile/array-of-buffers.slang.glsl @@ -36,11 +36,9 @@ out vec4 _S6; void main() { - vec4 _S7 = cb_0[C_0._data.index_0]._data.f_0; - S_0 _S8 = ((sb1_0[C_0._data.index_0])._data[(C_0._data.index_0)]); - vec4 _S9 = _S7 + _S8.f_0; - vec4 _S10 = _S9 + ((sb2_0[C_0._data.index_0])._data[(C_0._data.index_0)]); - uint _S11 = ((bb_0[C_0._data.index_0])._data[(int(C_0._data.index_0 * 4U))/4]); - _S6 = _S10 + vec4(float(_S11)); + S_0 _S7 = ((sb1_0[C_0._data.index_0])._data[(C_0._data.index_0)]); + vec4 _S8 = cb_0[C_0._data.index_0]._data.f_0 + _S7.f_0; + uint _S9 = ((bb_0[C_0._data.index_0])._data[(int(C_0._data.index_0 * 4U))/4]); + _S6 = _S8 + ((sb2_0[C_0._data.index_0])._data[(C_0._data.index_0)]) + vec4(float(_S9)); return; } diff --git a/tests/cross-compile/array-of-buffers.slang.hlsl b/tests/cross-compile/array-of-buffers.slang.hlsl index 960957789..e709d323a 100644 --- a/tests/cross-compile/array-of-buffers.slang.hlsl +++ b/tests/cross-compile/array-of-buffers.slang.hlsl @@ -27,10 +27,8 @@ RWStructuredBuffer<float4 > sb2_0[int(5)] : register(u0); ByteAddressBuffer bb_0[int(6)] : register(t4); float4 main() : SV_TARGET { - float4 _S1 = cb_0[C_0.index_0].f_0; - S_0 _S2 = sb1_0[C_0.index_0][C_0.index_0]; - float4 _S3 = _S1 + _S2.f_0; - float4 _S4 = _S3 + sb2_0[C_0.index_0][C_0.index_0]; - uint _S5 = bb_0[C_0.index_0].Load(int(C_0.index_0 * 4U)); - return _S4 + (float4)float(_S5); + S_0 _S1 = sb1_0[C_0.index_0][C_0.index_0]; + float4 _S2 = cb_0[C_0.index_0].f_0 + _S1.f_0; + uint _S3 = bb_0[C_0.index_0].Load(int(C_0.index_0 * 4U)); + return _S2 + sb2_0[C_0.index_0][C_0.index_0] + (float4)float(_S3); } |
