From e7b6de334f320429462a0257e2191ccf3cbc9a0d Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 24 Jan 2024 15:36:49 -0800 Subject: [SPIRV] Support `globallycoherent` and `[vk::index()]`. (#3488) * [SPIRV] Support `globallycoherent` modifier. * Fix. * Disable executable cooperative vector tests. * Update expected failure. * [SPIRV] Emit varying output index decoration. * Add test. * Update tests. * Fix test. * Emit `SpvExecutionModeEarlyFragmentTests`. * Lower `StructuredBuffer`. * Support globallycoherent on ByteAddressBuffer. --------- Co-authored-by: Yong He --- .gitignore | 2 +- source/slang/slang-check-modifier.cpp | 6 +- source/slang/slang-emit-glsl.cpp | 13 ++- source/slang/slang-emit-spirv.cpp | 95 ++++++++++++++++------ source/slang/slang-ir-byte-address-legalize.cpp | 17 +++- source/slang/slang-ir-glsl-legalize.cpp | 50 +++++++++--- .../slang/slang-ir-lower-buffer-element-type.cpp | 2 +- tests/bindings/glsl-parameter-blocks.slang.glsl | 6 +- tests/bugs/gh-841.slang | 1 - tests/bugs/gh-941.slang.glsl | 4 +- tests/bugs/vk-image-atomics.slang.glsl | 4 +- tests/bugs/vk-structured-buffer-binding.hlsl.glsl | 6 +- tests/compute/half-texture.slang | 10 ++- tests/cross-compile/array-of-buffers.slang.glsl | 4 +- tests/cross-compile/barycentrics-nv.slang.glsl | 4 +- tests/cross-compile/barycentrics.slang.glsl | 4 +- .../cross-compile/dual-source-blending.slang.glsl | 22 ++--- tests/cross-compile/early-depth-stencil.hlsl.glsl | 4 +- tests/cross-compile/geometry-shader.slang | 8 +- tests/cross-compile/geometry-shader.slang.glsl | 10 +-- .../glsl-empty-struct-param-field.slang.glsl | 4 +- tests/cross-compile/glsl-generic-in.slang | 7 +- tests/cross-compile/glsl-generic-in.slang.glsl | 8 +- tests/cross-compile/glsl-samplecmplevelzero.slang | 4 +- tests/cross-compile/half-conversion.slang.glsl | 4 +- .../cross-compile/non-uniform-indexing.slang.glsl | 6 +- tests/cross-compile/precise-keyword.slang | 4 +- tests/cross-compile/sign.slang.glsl | 4 +- tests/cross-compile/sv-coverage.slang.glsl | 10 +-- .../cross-compile/unknown-image-format.slang.glsl | 4 +- tests/cross-compile/vector-comparison.slang.glsl | 4 +- .../cross-compile/vk-push-constant-set.slang.glsl | 4 +- tests/expected-failure.txt | 6 ++ .../saturated-cooperation/fuse-product.slang | 4 +- .../saturated-cooperation/fuse.slang | 4 +- .../saturated-cooperation/fuse3.slang | 4 +- .../saturated-cooperation/simple.slang | 4 +- .../get-attribute-at-vertex-nv.slang.glsl | 6 +- .../get-attribute-at-vertex.slang.glsl | 6 +- .../rasterization/mesh/component-write.slang.glsl | 4 +- .../rasterization/mesh/hlsl-syntax.slang.glsl | 4 +- .../mesh/nested-component-write.slang.glsl | 4 +- .../rasterization/mesh/passing-outputs.slang | 4 +- .../rasterization/mesh/primitive-output.slang.glsl | 8 +- tests/spirv/coherent-2.slang | 15 ++++ tests/spirv/coherent.slang | 20 +++++ tests/spirv/varying-out-index.slang | 25 ++++++ 47 files changed, 315 insertions(+), 138 deletions(-) create mode 100644 tests/spirv/coherent-2.slang create mode 100644 tests/spirv/coherent.slang create mode 100644 tests/spirv/varying-out-index.slang diff --git a/.gitignore b/.gitignore index 3307bd9e1..1d58f6f6d 100644 --- a/.gitignore +++ b/.gitignore @@ -52,7 +52,7 @@ tools/gfx-unit-test/test-tmp-* # Intermediate source files generated during build process /source/slang/slang-generated-*.h -/source/slang/slang-lookup-capability-defs.cpp +/source/slang/slang-lookup-*.cpp /source/slang/*.meta.slang.h prelude/*.h.cpp /source/slang/cpp.hint diff --git a/source/slang/slang-check-modifier.cpp b/source/slang/slang-check-modifier.cpp index c9800b325..413e1c157 100644 --- a/source/slang/slang-check-modifier.cpp +++ b/source/slang/slang-check-modifier.cpp @@ -1033,9 +1033,12 @@ namespace Slang case ASTNodeType::RayPayloadAccessSemantic: case ASTNodeType::RayPayloadReadSemantic: case ASTNodeType::RayPayloadWriteSemantic: - case ASTNodeType::GloballyCoherentModifier: return (as(decl) && isGlobalDecl(decl)) || as(decl) || as(decl); + case ASTNodeType::GloballyCoherentModifier: + case ASTNodeType::HLSLVolatileModifier: + return as(decl) && (isGlobalDecl(decl) || as(getParentDecl(decl)) || as(decl)); + // Allowed only on parameters, struct fields and global variables. case ASTNodeType::InterpolationModeModifier: case ASTNodeType::HLSLNoInterpolationModifier: @@ -1090,7 +1093,6 @@ namespace Slang case ASTNodeType::HLSLColumnMajorLayoutModifier: case ASTNodeType::GLSLRowMajorLayoutModifier: case ASTNodeType::HLSLEffectSharedModifier: - case ASTNodeType::HLSLVolatileModifier: return as(decl) || as(decl); case ASTNodeType::GLSLPrecisionModifier: diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp index bff82acf3..0fc0c855a 100644 --- a/source/slang/slang-emit-glsl.cpp +++ b/source/slang/slang-emit-glsl.cpp @@ -179,7 +179,7 @@ void GLSLSourceEmitter::_emitGLSLStructuredBuffer(IRGlobalParam* varDecl, IRHLSL m_writer->emit(space); } } - + m_writer->emit(") "); /* @@ -194,7 +194,10 @@ void GLSLSourceEmitter::_emitGLSLStructuredBuffer(IRGlobalParam* varDecl, IRHLSL HLSLAppendStructuredBufferType - Write HLSLConsumeStructuredBufferType - TODO (JS): Its possible that this can be readonly, but we currently don't support on GLSL */ - + if (varDecl->findDecoration()) + { + m_writer->emit("coherent "); + } if (as(structuredBufferType)) { m_writer->emit("readonly "); @@ -264,9 +267,13 @@ void GLSLSourceEmitter::_emitGLSLByteAddressBuffer(IRGlobalParam* varDecl, IRByt m_writer->emit(space); } } - m_writer->emit(") "); + if (varDecl->findDecoration()) + { + m_writer->emit("coherent "); + } + /* If the output type is a buffer, and we can determine it is only readonly we can prefix before buffer with 'readonly' diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index a2a0bff58..4e11a7d86 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -1836,6 +1836,14 @@ struct SPIRVEmitContext varInst, SpvLiteralInteger::from32(int32_t(index)) ); + if (space != 0) + { + emitOpDecorateIndex( + getSection(SpvLogicalSectionID::Annotations), + nullptr, + varInst, + SpvLiteralInteger::from32(int32_t(space))); + } break; case LayoutResourceKind::VaryingOutput: emitOpDecorateLocation( @@ -1844,6 +1852,14 @@ struct SPIRVEmitContext varInst, SpvLiteralInteger::from32(int32_t(index)) ); + if (space != 0) + { + emitOpDecorateIndex( + getSection(SpvLogicalSectionID::Annotations), + nullptr, + varInst, + SpvLiteralInteger::from32(int32_t(space))); + } break; case LayoutResourceKind::SpecializationConstant: @@ -1988,6 +2004,7 @@ struct SPIRVEmitContext if(layout) emitVarLayout(globalVar, varInst, layout); maybeEmitName(varInst, globalVar); + emitDecorations(globalVar, getID(varInst)); return varInst; } @@ -2743,10 +2760,6 @@ struct SPIRVEmitContext default: break; } - if (entryPointDecor->getProfile().getStage() == Stage::Fragment) - { - maybeEmitEntryPointDepthReplacingExecutionMode(entryPoint, referencedBuiltinIRVars); - } } // Add remaining builtin variables that does not have a corresponding IR global var/param. // These variables could be added from SPIRV ASM blocks. @@ -2769,7 +2782,19 @@ struct SPIRVEmitContext { case Stage::Fragment: //OpExecutionMode %main OriginUpperLeft - emitInst(getSection(SpvLogicalSectionID::ExecutionModes), nullptr, SpvOpExecutionMode, dstID, SpvExecutionModeOriginUpperLeft); + emitOpExecutionMode(getSection(SpvLogicalSectionID::ExecutionModes), nullptr, dstID, SpvExecutionModeOriginUpperLeft); + maybeEmitEntryPointDepthReplacingExecutionMode(entryPoint, referencedBuiltinIRVars); + for (auto decor : entryPoint->getDecorations()) + { + switch (decor->getOp()) + { + case kIROp_EarlyDepthStencilDecoration: + emitOpExecutionMode(getSection(SpvLogicalSectionID::ExecutionModes), nullptr, dstID, SpvExecutionModeEarlyFragmentTests); + break; + default: + break; + } + } break; case Stage::Geometry: requireSPIRVCapability(SpvCapabilityGeometry); @@ -2787,7 +2812,6 @@ struct SPIRVEmitContext } } break; - // > OpExecutionMode // [3.6. Execution Mode]: LocalSize @@ -2937,6 +2961,12 @@ struct SPIRVEmitContext dstID, SpvLiteralInteger::from32(int32_t(getIntVal(decoration->getOperand(0))))); break; + case kIROp_GloballyCoherentDecoration: + emitOpDecorate(getSection(SpvLogicalSectionID::Annotations), + decoration, + dstID, + SpvDecorationCoherent); + break; // ... } @@ -3007,14 +3037,40 @@ struct SPIRVEmitContext int32_t id = 0; for (auto field : structType->getFields()) { - if (auto fieldNameDecor = field->getKey()->findDecoration()) + for (auto decor : field->getKey()->getDecorations()) { - emitOpMemberName( - getSection(SpvLogicalSectionID::DebugNames), - nullptr, - spvStructID, - id, - fieldNameDecor->getName()); + if (auto fieldNameDecor = as(decor)) + { + emitOpMemberName( + getSection(SpvLogicalSectionID::DebugNames), + nullptr, + spvStructID, + id, + fieldNameDecor->getName()); + } + else if (as(decor)) + { + emitOpMemberDecorate( + getSection(SpvLogicalSectionID::Annotations), + decor, + spvStructID, + SpvLiteralInteger::from32(id), + SpvDecorationCoherent + ); + } + else if (auto semanticDecor = field->getKey()->findDecoration()) + { + if (shouldEmitSPIRVReflectionInfo()) + { + emitOpMemberDecorateString( + getSection(SpvLogicalSectionID::Annotations), + nullptr, + spvStructID, + SpvLiteralInteger::from32(id), + SpvDecorationUserSemantic, + semanticDecor->getSemanticName()); + } + } } IRIntegerValue offset = 0; @@ -3090,19 +3146,6 @@ struct SPIRVEmitContext SpvLiteralInteger::from32(id), SpvLiteralInteger::from32((int32_t)matrixStride)); } - if (shouldEmitSPIRVReflectionInfo()) - { - if (auto semanticDecor = field->getKey()->findDecoration()) - { - emitOpMemberDecorateString( - getSection(SpvLogicalSectionID::Annotations), - nullptr, - spvStructID, - SpvLiteralInteger::from32(id), - SpvDecorationUserSemantic, - semanticDecor->getSemanticName()); - } - } id++; } } diff --git a/source/slang/slang-ir-byte-address-legalize.cpp b/source/slang/slang-ir-byte-address-legalize.cpp index e405dd606..eec620133 100644 --- a/source/slang/slang-ir-byte-address-legalize.cpp +++ b/source/slang/slang-ir-byte-address-legalize.cpp @@ -717,6 +717,21 @@ struct ByteAddressBufferLegalizationContext return structuredBufferParam; } + void cloneBufferDecorations(IRBuilder& builder, IRInst* dest, IRInst* src) + { + for (auto decoration : src->getDecorations()) + { + switch (decoration->getOp()) + { + case kIROp_GloballyCoherentDecoration: + builder.addDecoration(dest, decoration->getOp()); + break; + default: + break; + } + } + } + IRGlobalParam* createEquivalentStructuredBufferParam(IRType* elementType, IRGlobalParam* byteAddressBufferParam) { // When we need to create a new structured buffer to stand in for @@ -751,7 +766,7 @@ struct ByteAddressBufferLegalizationContext { paramBuilder.addLayoutDecoration(structuredBufferParam, layoutDecoration->getLayout()); } - + cloneBufferDecorations(paramBuilder, structuredBufferParam, byteAddressBufferParam); return structuredBufferParam; } diff --git a/source/slang/slang-ir-glsl-legalize.cpp b/source/slang/slang-ir-glsl-legalize.cpp index 65efde214..0d279549c 100644 --- a/source/slang/slang-ir-glsl-legalize.cpp +++ b/source/slang/slang-ir-glsl-legalize.cpp @@ -1023,7 +1023,8 @@ ScalarizedVal createSimpleGLSLGlobalVarying( UInt bindingIndex, UInt bindingSpace, GlobalVaryingDeclarator* declarator, - IRInst* leafVar) + IRInst* leafVar, + StringBuilder& nameHintSB) { // Check if we have a system value on our hands. GLSLSystemValueInfo systemValueInfoStorage; @@ -1221,6 +1222,13 @@ ScalarizedVal createSimpleGLSLGlobalVarying( } } } + else + { + if (nameHintSB.getLength()) + { + builder->addNameHintDecoration(globalParam, nameHintSB.getUnownedSlice()); + } + } createVarLayoutForLegalizedGlobalParam( globalParam, builder, inVarLayout, typeLayout, kind, bindingIndex, bindingSpace, declarator, leafVar, systemValueInfo); @@ -1239,7 +1247,8 @@ ScalarizedVal createGLSLGlobalVaryingsImpl( UInt bindingIndex, UInt bindingSpace, GlobalVaryingDeclarator* declarator, - IRInst* leafVar) + IRInst* leafVar, + StringBuilder& nameHintSB) { if (as(type)) { @@ -1250,14 +1259,14 @@ ScalarizedVal createGLSLGlobalVaryingsImpl( return createSimpleGLSLGlobalVarying( context, codeGenContext, - builder, type, varLayout, typeLayout, kind, stage, bindingIndex, bindingSpace, declarator, leafVar); + builder, type, varLayout, typeLayout, kind, stage, bindingIndex, bindingSpace, declarator, leafVar, nameHintSB); } else if( as(type) ) { return createSimpleGLSLGlobalVarying( context, codeGenContext, - builder, type, varLayout, typeLayout, kind, stage, bindingIndex, bindingSpace, declarator, leafVar); + builder, type, varLayout, typeLayout, kind, stage, bindingIndex, bindingSpace, declarator, leafVar, nameHintSB); } else if( as(type) ) { @@ -1265,7 +1274,7 @@ ScalarizedVal createGLSLGlobalVaryingsImpl( return createSimpleGLSLGlobalVarying( context, codeGenContext, - builder, type, varLayout, typeLayout, kind, stage, bindingIndex, bindingSpace, declarator, leafVar); + builder, type, varLayout, typeLayout, kind, stage, bindingIndex, bindingSpace, declarator, leafVar, nameHintSB); } else if( auto arrayType = as(type) ) { @@ -1294,7 +1303,8 @@ ScalarizedVal createGLSLGlobalVaryingsImpl( bindingIndex, bindingSpace, &arrayDeclarator, - leafVar); + leafVar, + nameHintSB); } else if( auto meshOutputType = as(type)) { @@ -1337,7 +1347,8 @@ ScalarizedVal createGLSLGlobalVaryingsImpl( bindingIndex, bindingSpace, &arrayDeclarator, - leafVar); + leafVar, + nameHintSB); } else if( auto streamType = as(type)) { @@ -1358,7 +1369,8 @@ ScalarizedVal createGLSLGlobalVaryingsImpl( bindingIndex, bindingSpace, declarator, - leafVar); + leafVar, + nameHintSB); } else if(auto structType = as(type)) { @@ -1394,6 +1406,8 @@ ScalarizedVal createGLSLGlobalVaryingsImpl( // Okay, we want to walk through the fields here, and // generate one variable for each. UInt fieldCounter = 0; + auto nameSBLength = nameHintSB.getLength(); + for(auto field : structType->getFields()) { UInt fieldIndex = fieldCounter++; @@ -1407,7 +1421,13 @@ ScalarizedVal createGLSLGlobalVaryingsImpl( fieldBindingIndex += fieldResInfo->getOffset(); fieldBindingSpace += fieldResInfo->getSpace(); } - + nameHintSB.reduceLength(nameSBLength); + if (auto fieldNameHint = field->getKey()->findDecoration()) + { + if (nameHintSB.getLength() != 0) + nameHintSB << "."; + nameHintSB << fieldNameHint->getName(); + } auto fieldVal = createGLSLGlobalVaryingsImpl( context, codeGenContext, @@ -1420,7 +1440,8 @@ ScalarizedVal createGLSLGlobalVaryingsImpl( fieldBindingIndex, fieldBindingSpace, declarator, - field); + field, + nameHintSB); if (fieldVal.flavor != ScalarizedVal::Flavor::none) { ScalarizedTupleValImpl::Element element; @@ -1438,7 +1459,7 @@ ScalarizedVal createGLSLGlobalVaryingsImpl( return createSimpleGLSLGlobalVarying( context, codeGenContext, - builder, type, varLayout, typeLayout, kind, stage, bindingIndex, bindingSpace, declarator, leafVar); + builder, type, varLayout, typeLayout, kind, stage, bindingIndex, bindingSpace, declarator, leafVar, nameHintSB); } ScalarizedVal createGLSLGlobalVaryings( @@ -1458,10 +1479,15 @@ ScalarizedVal createGLSLGlobalVaryings( bindingIndex = rr->getOffset(); bindingSpace = rr->getSpace(); } + StringBuilder namehintSB; + if (auto nameHint = leafVar->findDecoration()) + { + namehintSB << nameHint->getName(); + } return createGLSLGlobalVaryingsImpl( context, codeGenContext, - builder, type, layout, layout->getTypeLayout(), kind, stage, bindingIndex, bindingSpace, nullptr, leafVar); + builder, type, layout, layout->getTypeLayout(), kind, stage, bindingIndex, bindingSpace, nullptr, leafVar, namehintSB); } ScalarizedVal extractField( diff --git a/source/slang/slang-ir-lower-buffer-element-type.cpp b/source/slang/slang-ir-lower-buffer-element-type.cpp index 378201fdb..6cd8495b4 100644 --- a/source/slang/slang-ir-lower-buffer-element-type.cpp +++ b/source/slang/slang-ir-lower-buffer-element-type.cpp @@ -515,7 +515,7 @@ namespace Slang elementType = constBuffer->getElementType(); if (as(globalInst)) continue; - if (!as(elementType) && !as(elementType) && !as(elementType)) + if (!as(elementType) && !as(elementType) && !as(elementType) && !as(elementType)) continue; bufferTypeInsts.add(BufferTypeInfo{ (IRType*)globalInst, elementType }); } diff --git a/tests/bindings/glsl-parameter-blocks.slang.glsl b/tests/bindings/glsl-parameter-blocks.slang.glsl index c00ed8fe3..4bea5b8c3 100644 --- a/tests/bindings/glsl-parameter-blocks.slang.glsl +++ b/tests/bindings/glsl-parameter-blocks.slang.glsl @@ -18,14 +18,14 @@ layout(binding = 2) uniform sampler gTest_s_0; layout(location = 0) -out vec4 _S2; +out vec4 main_0; layout(location = 0) -in vec2 _S3; +in vec2 uv_0; void main() { - _S2 = gTest_0.a_0 + (texture(sampler2D(gTest_t_0,gTest_s_0), (_S3))); + main_0 = gTest_0.a_0 + (texture(sampler2D(gTest_t_0,gTest_s_0), (uv_0))); return; } diff --git a/tests/bugs/gh-841.slang b/tests/bugs/gh-841.slang index 0608023e5..ba746984b 100644 --- a/tests/bugs/gh-841.slang +++ b/tests/bugs/gh-841.slang @@ -1,6 +1,5 @@ // gh-841.slang -//TEST:CROSS_COMPILE: -profile ps_5_0 -entry main -target spirv-assembly //TEST:CROSS_COMPILE(filecheck=SPV): -profile ps_5_0 -entry main -target spirv-assembly //TEST:CROSS_COMPILE(filecheck=GLSL): -profile ps_5_0 -entry main -target glsl diff --git a/tests/bugs/gh-941.slang.glsl b/tests/bugs/gh-941.slang.glsl index 111cdb33c..9c82d070d 100644 --- a/tests/bugs/gh-941.slang.glsl +++ b/tests/bugs/gh-941.slang.glsl @@ -21,11 +21,11 @@ layout(binding = 1) uniform sampler s_0; layout(location = 0) -out vec4 _S2; +out vec4 main_0; void main() { - _S2 = (texture(sampler2D(t_0[C_0.index_0],s_0), (C_0.uv_0))); + main_0 = (texture(sampler2D(t_0[C_0.index_0],s_0), (C_0.uv_0))); return; } diff --git a/tests/bugs/vk-image-atomics.slang.glsl b/tests/bugs/vk-image-atomics.slang.glsl index 2ed19bffa..d72bdd10f 100644 --- a/tests/bugs/vk-image-atomics.slang.glsl +++ b/tests/bugs/vk-image-atomics.slang.glsl @@ -5,12 +5,12 @@ layout(binding = 0) uniform uimage2D t_0; layout(location = 0) -out vec4 _S1; +out vec4 main_0; void main() { uint u_0; u_0 = imageAtomicAdd(t_0, ivec2(uvec2(0)), 1); - _S1 = vec4(u_0); + main_0 = vec4(u_0); return; } diff --git a/tests/bugs/vk-structured-buffer-binding.hlsl.glsl b/tests/bugs/vk-structured-buffer-binding.hlsl.glsl index f108aac00..18ed1a8a7 100644 --- a/tests/bugs/vk-structured-buffer-binding.hlsl.glsl +++ b/tests/bugs/vk-structured-buffer-binding.hlsl.glsl @@ -10,14 +10,14 @@ layout(std430, binding = 3, set = 4) buffer StructuredBuffer_uint_t_0 { } gDoneGroups_0; layout(location = 0) -out vec4 _S1; +out vec4 main_0; layout(location = 0) -in vec3 _S2; +in vec3 uv_0; void main() { - _S1 = vec4(float(gDoneGroups_0._data[uint(int(_S2.z))])); + main_0 = vec4(float(gDoneGroups_0._data[uint(int(uv_0.z))])); return; } diff --git a/tests/compute/half-texture.slang b/tests/compute/half-texture.slang index c87f4359c..bdf98cb77 100644 --- a/tests/compute/half-texture.slang +++ b/tests/compute/half-texture.slang @@ -1,4 +1,4 @@ -//TEST:CROSS_COMPILE: -target spirv -entry computeMain -profile cs_6_2 +//TEST:SIMPLE(filecheck=CHECK): -target spirv -entry computeMain -profile cs_6_2 //TEST:CROSS_COMPILE: -target dxil-assembly -entry computeMain -profile cs_6_2 //TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=16):out @@ -26,8 +26,14 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) half2 h2 = halfTexture2.Sample(s, uv); half4 h4 = halfTexture4.Sample(s, uv); #else - half h = halfTexture[pos2]; + // CHECK: {{.*}} = OpImageRead + // CHECK: {{.*}} = OpFConvert %half + half h = halfTexture[pos2]; + // CHECK: {{.*}} = OpImageRead + // CHECK: {{.*}} = OpFConvert %v2half half2 h2 = halfTexture2[pos2]; + // CHECK: {{.*}} = OpImageRead + // CHECK: {{.*}} = OpFConvert %v4half half4 h4 = halfTexture4[pos2]; #endif // Store a results diff --git a/tests/cross-compile/array-of-buffers.slang.glsl b/tests/cross-compile/array-of-buffers.slang.glsl index 53a826a91..0b0af50bf 100644 --- a/tests/cross-compile/array-of-buffers.slang.glsl +++ b/tests/cross-compile/array-of-buffers.slang.glsl @@ -30,10 +30,10 @@ layout(std430, binding = 4) readonly buffer StructuredBuffer_uint_t_0 { uint _data[]; } bb_0[6]; layout(location = 0) -out vec4 _S3; +out vec4 main_0; void main() { - _S3 = cb_0[C_0.index_0].f_0 + sb1_0[C_0.index_0]._data[C_0.index_0].f_0 + sb2_0[C_0.index_0]._data[C_0.index_0] + vec4(float(bb_0[C_0.index_0]._data[int(C_0.index_0 * 4U) / 4])); + main_0 = cb_0[C_0.index_0].f_0 + sb1_0[C_0.index_0]._data[C_0.index_0].f_0 + sb2_0[C_0.index_0]._data[C_0.index_0] + vec4(float(bb_0[C_0.index_0]._data[int(C_0.index_0 * 4U) / 4])); return; } diff --git a/tests/cross-compile/barycentrics-nv.slang.glsl b/tests/cross-compile/barycentrics-nv.slang.glsl index ca37a14e8..583310125 100644 --- a/tests/cross-compile/barycentrics-nv.slang.glsl +++ b/tests/cross-compile/barycentrics-nv.slang.glsl @@ -3,10 +3,10 @@ #extension GL_NV_fragment_shader_barycentric : enable layout(location = 0) -out vec4 _S1; +out vec4 main_0; void main() { - _S1 = vec4(gl_BaryCoordNV, float(0)); + main_0 = vec4(gl_BaryCoordNV, float(0)); return; } diff --git a/tests/cross-compile/barycentrics.slang.glsl b/tests/cross-compile/barycentrics.slang.glsl index 963316b53..ede585db0 100644 --- a/tests/cross-compile/barycentrics.slang.glsl +++ b/tests/cross-compile/barycentrics.slang.glsl @@ -3,10 +3,10 @@ #extension GL_EXT_fragment_shader_barycentric : enable layout(location = 0) -out vec4 _S1; +out vec4 main_0; void main() { - _S1 = vec4(gl_BaryCoordEXT, float(0)); + main_0 = vec4(gl_BaryCoordEXT, float(0)); return; } diff --git a/tests/cross-compile/dual-source-blending.slang.glsl b/tests/cross-compile/dual-source-blending.slang.glsl index aa550b451..0cdd0fef6 100644 --- a/tests/cross-compile/dual-source-blending.slang.glsl +++ b/tests/cross-compile/dual-source-blending.slang.glsl @@ -5,13 +5,13 @@ layout(row_major) uniform; layout(row_major) buffer; layout(location = 0) -out vec4 _S1; +out vec4 main_a_0; layout(location = 0, index = 1) -out vec4 _S2; +out vec4 main_b_0; layout(location = 0) -in vec4 _S3; +in vec4 v_0; struct FragmentOutput_0 { @@ -21,17 +21,17 @@ struct FragmentOutput_0 void main() { - const vec4 _S4 = vec4(0.0, 0.0, 0.0, 0.0); + const vec4 _S1 = vec4(0.0, 0.0, 0.0, 0.0); FragmentOutput_0 f_0; - f_0.a_0 = _S4; + f_0.a_0 = _S1; - f_0.b_0 = _S4; - f_0.a_0 = _S3; - f_0.b_0 = _S3; - FragmentOutput_0 _S5 = f_0; - _S1 = f_0.a_0; - _S2 = _S5.b_0; + f_0.b_0 = _S1; + f_0.a_0 = v_0; + f_0.b_0 = v_0; + FragmentOutput_0 _S2 = f_0; + main_a_0 = f_0.a_0; + main_b_0 = _S2.b_0; return; } diff --git a/tests/cross-compile/early-depth-stencil.hlsl.glsl b/tests/cross-compile/early-depth-stencil.hlsl.glsl index 73e258a82..4a723215c 100644 --- a/tests/cross-compile/early-depth-stencil.hlsl.glsl +++ b/tests/cross-compile/early-depth-stencil.hlsl.glsl @@ -5,12 +5,12 @@ layout(row_major) buffer; #line 5 0 layout(location = 0) -out vec4 _S1; +out vec4 main_0; #line 5 layout(early_fragment_tests) in; void main() { - _S1 = vec4(float(1), float(0), float(0), float(1)); + main_0 = vec4(float(1), float(0), float(0), float(1)); return; } diff --git a/tests/cross-compile/geometry-shader.slang b/tests/cross-compile/geometry-shader.slang index 8666b739a..98e5fe661 100644 --- a/tests/cross-compile/geometry-shader.slang +++ b/tests/cross-compile/geometry-shader.slang @@ -1,6 +1,7 @@ // geometry-shader.slang -//TEST:CROSS_COMPILE: -profile sm_5_0 -stage geometry -entry main -target spirv-assembly +//TEST:SIMPLE(filecheck=CHECK): -profile sm_5_0 -stage geometry -entry main -target glsl +//TEST:SIMPLE(filecheck=SPIRV): -profile sm_5_0 -stage geometry -entry main -target spirv struct CoarseVertex { @@ -16,6 +17,11 @@ struct RasterVertex uint id : SV_RenderTargetArrayIndex; } +// SPIRV: OpEntryPoint +// CHECK: void main() +// CHECK: gl_Layer = +// CHECK: EmitVertex(); + [maxvertexcount(3)] void main( triangle CoarseVertex coarseVertices[3], diff --git a/tests/cross-compile/geometry-shader.slang.glsl b/tests/cross-compile/geometry-shader.slang.glsl index da7ae19cd..9f36b880d 100644 --- a/tests/cross-compile/geometry-shader.slang.glsl +++ b/tests/cross-compile/geometry-shader.slang.glsl @@ -5,11 +5,11 @@ #define RasterVertex RasterVertex_0 #define CoarseVertex CoarseVertex_0 -#define input_position _S1 -#define input_color _S2 -#define input_id _S3 -#define output_position _S4 -#define output_color _S5 +#define input_position coarseVertices_position_0 +#define input_color coarseVertices_color_0 +#define input_id coarseVertices_id_0 +#define output_position outputStream_position_0 +#define output_color outputStream_color_0 layout(row_major) uniform; layout(row_major) buffer; diff --git a/tests/cross-compile/glsl-empty-struct-param-field.slang.glsl b/tests/cross-compile/glsl-empty-struct-param-field.slang.glsl index acf0a6fe9..bff888233 100644 --- a/tests/cross-compile/glsl-empty-struct-param-field.slang.glsl +++ b/tests/cross-compile/glsl-empty-struct-param-field.slang.glsl @@ -14,10 +14,10 @@ layout(std140) uniform _S1 vec4 param_0; } pblock_0; layout(location = 0) -out vec4 _S2; +out vec4 main_0; void main() { - _S2 = pblock_0.param_0; + main_0 = pblock_0.param_0; return; } \ No newline at end of file diff --git a/tests/cross-compile/glsl-generic-in.slang b/tests/cross-compile/glsl-generic-in.slang index 90fe387ba..a43f33c21 100644 --- a/tests/cross-compile/glsl-generic-in.slang +++ b/tests/cross-compile/glsl-generic-in.slang @@ -1,4 +1,7 @@ -//TEST:CROSS_COMPILE:-target spirv-assembly -entry main -profile vs_5_0 +//TEST:SIMPLE(filecheck=CHECK): -target spirv-assembly -entry main -profile vs_5_0 +// CHECK: vIn_field_v0_0 = OpVariable %_ptr_Input_v4float Input +// CHECK: %vIn_field_v1_0 = OpVariable %_ptr_Input_v2float Input +// CHECK: %vIn_p0_0 = OpVariable %_ptr_Input_v3float Input interface IField { float get(); @@ -30,4 +33,4 @@ VOut main(GIn vIn) VOut vout; vout.projPos = float4(vIn.p0, vIn.field.get() + vIn.e.get()); return vout; -} \ No newline at end of file +} diff --git a/tests/cross-compile/glsl-generic-in.slang.glsl b/tests/cross-compile/glsl-generic-in.slang.glsl index 4bf0598d0..0aefb27f2 100644 --- a/tests/cross-compile/glsl-generic-in.slang.glsl +++ b/tests/cross-compile/glsl-generic-in.slang.glsl @@ -18,10 +18,10 @@ float E_get_0() } layout(location = 0) -in vec3 _S1; +in vec3 vIn_p0_0; layout(location = 1) -in vec4 _S2; +in vec4 vIn_field_v0_0; layout(location = 2) in vec2 _S3; @@ -32,9 +32,9 @@ struct VOut_0 }; void main() { - F_0 _S4 = { _S2, _S3 }; + F_0 _S4 = { vIn_field_v0_0, _S3 }; VOut_0 vout_0; - vout_0.projPos_0 = vec4(_S1, F_get_0(_S4) + E_get_0()); + vout_0.projPos_0 = vec4(vIn_p0_0, F_get_0(_S4) + E_get_0()); gl_Position = vout_0.projPos_0; return; } diff --git a/tests/cross-compile/glsl-samplecmplevelzero.slang b/tests/cross-compile/glsl-samplecmplevelzero.slang index cd2ee54bd..556addf80 100644 --- a/tests/cross-compile/glsl-samplecmplevelzero.slang +++ b/tests/cross-compile/glsl-samplecmplevelzero.slang @@ -1,7 +1,7 @@ //TEST:CROSS_COMPILE(filecheck=CHECK): -profile ps_5_0 -entry main -target glsl -// CHECK: float _S3 = (textureLod(sampler2DShadow(shadowMap_0,sampler_0), (_S2), 0)); -// CHECK: float _S4 = (textureLodOffset(sampler2DShadow(shadowMap_0,sampler_0), (_S2), 0, (ivec2(1, 1)))); +// CHECK: float {{.*}} = (textureLod(sampler2DShadow(shadowMap_0,sampler_0), ({{.*}}), 0)); +// CHECK: float {{.*}} = (textureLodOffset(sampler2DShadow(shadowMap_0,sampler_0), ({{.*}}), 0, (ivec2(1, 1)))); Texture2D shadowMap; SamplerComparisonState sampler; diff --git a/tests/cross-compile/half-conversion.slang.glsl b/tests/cross-compile/half-conversion.slang.glsl index b062f67b4..b9772c32e 100644 --- a/tests/cross-compile/half-conversion.slang.glsl +++ b/tests/cross-compile/half-conversion.slang.glsl @@ -31,10 +31,10 @@ vec4 f16tof32_0(uvec4 value_0) } layout(location = 0) -out vec4 _S2; +out vec4 main_0; void main() { - _S2 = f16tof32_0(C_0.u_0); + main_0 = f16tof32_0(C_0.u_0); return; } diff --git a/tests/cross-compile/non-uniform-indexing.slang.glsl b/tests/cross-compile/non-uniform-indexing.slang.glsl index 07e8f9e38..35b5fab95 100644 --- a/tests/cross-compile/non-uniform-indexing.slang.glsl +++ b/tests/cross-compile/non-uniform-indexing.slang.glsl @@ -9,14 +9,14 @@ layout(binding = 1) uniform sampler s_0; layout(location = 0) -out vec4 _S1; +out vec4 main_0; layout(location = 0) -in vec3 _S2; +in vec3 uv_0; void main() { - _S1 = (texture(sampler2D(t_0[nonuniformEXT(int(_S2.z))],s_0), (_S2.xy))); + main_0 = (texture(sampler2D(t_0[nonuniformEXT(int(uv_0.z))],s_0), (uv_0.xy))); return; } diff --git a/tests/cross-compile/precise-keyword.slang b/tests/cross-compile/precise-keyword.slang index 5ebfd35ad..9be605e0c 100644 --- a/tests/cross-compile/precise-keyword.slang +++ b/tests/cross-compile/precise-keyword.slang @@ -1,11 +1,13 @@ // precise-keyword.slang -//TEST:CROSS_COMPILE:-target spirv-assembly -entry main -stage fragment +//TEST:SIMPLE(filecheck=SPIRV): -target spirv-assembly -entry main -stage fragment //TEST:CROSS_COMPILE:-target dxbc-assembly -entry main -stage fragment //TEST:CROSS_COMPILE:-target dxil-assembly -entry main -stage fragment -profile sm_6_0 // Test handling of the `precise` keyword +// SPIRV: OpEntryPoint + float4 main(float2 v : V) : SV_Target { precise float z; diff --git a/tests/cross-compile/sign.slang.glsl b/tests/cross-compile/sign.slang.glsl index 44c015967..ec0bfe377 100644 --- a/tests/cross-compile/sign.slang.glsl +++ b/tests/cross-compile/sign.slang.glsl @@ -3,10 +3,10 @@ layout(row_major) uniform; layout(row_major) buffer; layout(location = 0) -out vec4 _S1; +out vec4 main_0; void main() { - _S1 = vec4((ivec4(sign((vec4(1.5, 1.0, -1.5, -1.0)))))); + main_0 = vec4((ivec4(sign((vec4(1.5, 1.0, -1.5, -1.0)))))); return; } diff --git a/tests/cross-compile/sv-coverage.slang.glsl b/tests/cross-compile/sv-coverage.slang.glsl index 2a8ff0734..a5e0dea47 100644 --- a/tests/cross-compile/sv-coverage.slang.glsl +++ b/tests/cross-compile/sv-coverage.slang.glsl @@ -2,15 +2,15 @@ #version 450 layout(location = 0) -out vec4 _S1; +out vec4 main_0; layout(location = 0) -in vec4 _S2; +in vec4 color_0; void main() { - uint _S3 = uint(gl_SampleMaskIn[0]) ^ uint(1); - _S1 = _S2; - gl_SampleMask[0] = int(_S3); + uint _S1 = uint(gl_SampleMaskIn[0]) ^ uint(1); + main_0 = color_0; + gl_SampleMask[0] = int(_S1); return; } diff --git a/tests/cross-compile/unknown-image-format.slang.glsl b/tests/cross-compile/unknown-image-format.slang.glsl index e541a8b17..a39cf3693 100644 --- a/tests/cross-compile/unknown-image-format.slang.glsl +++ b/tests/cross-compile/unknown-image-format.slang.glsl @@ -39,7 +39,7 @@ layout(binding = 4) uniform image2D entryPointParams_explicitFormat_0; layout(location = 0) -out vec4 _S2; +out vec4 main_0; void main() { @@ -60,7 +60,7 @@ void main() vec4 result_3 = result_2 + _S8; vec4 _S9 = (imageLoad((entryPointParams_explicitFormat_0), ivec2((C_0.index_0)))); - _S2 = result_3 + _S9; + main_0 = result_3 + _S9; return; } diff --git a/tests/cross-compile/vector-comparison.slang.glsl b/tests/cross-compile/vector-comparison.slang.glsl index f7c28203e..f3f103678 100644 --- a/tests/cross-compile/vector-comparison.slang.glsl +++ b/tests/cross-compile/vector-comparison.slang.glsl @@ -14,13 +14,13 @@ layout(std140) uniform _S1 vec4 b_0; } params_0; layout(location = 0) -out vec4 _S2; +out vec4 main_0; void main() { const vec4 _S3 = vec4(2.0); const vec4 _S4 = vec4(3.0); - _S2 = mix(_S4, _S3, (equal(params_0.a_0,params_0.b_0))) + mix(_S4, _S3, (lessThan(params_0.a_0,params_0.b_0))) + mix(_S4, _S3, (greaterThan(params_0.a_0,params_0.b_0))) + mix(_S4, _S3, (lessThanEqual(params_0.a_0,params_0.b_0))) + mix(_S4, _S3, (greaterThanEqual(params_0.a_0,params_0.b_0))) + mix(_S4, _S3, (notEqual(params_0.a_0,params_0.b_0))); + main_0 = mix(_S4, _S3, (equal(params_0.a_0,params_0.b_0))) + mix(_S4, _S3, (lessThan(params_0.a_0,params_0.b_0))) + mix(_S4, _S3, (greaterThan(params_0.a_0,params_0.b_0))) + mix(_S4, _S3, (lessThanEqual(params_0.a_0,params_0.b_0))) + mix(_S4, _S3, (greaterThanEqual(params_0.a_0,params_0.b_0))) + mix(_S4, _S3, (notEqual(params_0.a_0,params_0.b_0))); return; } diff --git a/tests/cross-compile/vk-push-constant-set.slang.glsl b/tests/cross-compile/vk-push-constant-set.slang.glsl index 7a2ce4db0..dde1c9413 100644 --- a/tests/cross-compile/vk-push-constant-set.slang.glsl +++ b/tests/cross-compile/vk-push-constant-set.slang.glsl @@ -19,10 +19,10 @@ layout(std140) uniform _S2 } y_0; layout(location = 0) -out vec4 _S3; +out vec4 main_0; void main() { - _S3 = x_0.v_0 + y_0.v_0; + main_0 = x_0.v_0 + y_0.v_0; return; } diff --git a/tests/expected-failure.txt b/tests/expected-failure.txt index e69de29bb..64d116ec9 100644 --- a/tests/expected-failure.txt +++ b/tests/expected-failure.txt @@ -0,0 +1,6 @@ +tests/language-feature/saturated-cooperation/simple.slang (vk) +tests/language-feature/saturated-cooperation/fuse3.slang (vk) +tests/language-feature/saturated-cooperation/fuse-product.slang (vk) +tests/language-feature/saturated-cooperation/fuse.slang (vk) +tests/bugs/byte-address-buffer-interlocked-add-f32.slang (vk) +tests/ir/loop-unroll-0.slang.1 (vk) diff --git a/tests/language-feature/saturated-cooperation/fuse-product.slang b/tests/language-feature/saturated-cooperation/fuse-product.slang index d59df2db3..6f5545d7d 100644 --- a/tests/language-feature/saturated-cooperation/fuse-product.slang +++ b/tests/language-feature/saturated-cooperation/fuse-product.slang @@ -1,5 +1,5 @@ -//TEST(compute, vulkan):COMPARE_COMPUTE_EX():-vk -compute -shaderobj -output-using-type -render-features wave-ops -//TEST(compute):COMPARE_COMPUTE_EX():-dx12 -profile sm_6_5 -use-dxil -compute -shaderobj -output-using-type -render-features wave-ops +//DISABLED_TEST(compute, vulkan):COMPARE_COMPUTE_EX():-vk -compute -shaderobj -output-using-type -render-features wave-ops +//DISABLED_TEST(compute):COMPARE_COMPUTE_EX():-dx12 -profile sm_6_5 -use-dxil -compute -shaderobj -output-using-type -render-features wave-ops //TEST:SIMPLE(filecheck=CHECK):-target hlsl -profile cs_6_5 -entry computeMain -line-directive-mode none //TEST:SIMPLE(filecheck=CHECK):-target glsl -profile cs_6_5 -entry computeMain -line-directive-mode none diff --git a/tests/language-feature/saturated-cooperation/fuse.slang b/tests/language-feature/saturated-cooperation/fuse.slang index 5feb46e2e..4eaf90a4a 100644 --- a/tests/language-feature/saturated-cooperation/fuse.slang +++ b/tests/language-feature/saturated-cooperation/fuse.slang @@ -1,5 +1,5 @@ -//TEST(compute, vulkan):COMPARE_COMPUTE_EX():-vk -compute -shaderobj -output-using-type -render-features wave-ops -//TEST(compute):COMPARE_COMPUTE_EX():-dx12 -profile sm_6_5 -use-dxil -compute -shaderobj -output-using-type -render-features wave-ops +//DISABLED_TEST(compute, vulkan):COMPARE_COMPUTE_EX():-vk -compute -shaderobj -output-using-type -render-features wave-ops +//DISABLED_TEST(compute):COMPARE_COMPUTE_EX():-dx12 -profile sm_6_5 -use-dxil -compute -shaderobj -output-using-type -render-features wave-ops // // This test checks whether adjacent calls to saturated_cooperation are fused diff --git a/tests/language-feature/saturated-cooperation/fuse3.slang b/tests/language-feature/saturated-cooperation/fuse3.slang index 884f65652..d2824b67d 100644 --- a/tests/language-feature/saturated-cooperation/fuse3.slang +++ b/tests/language-feature/saturated-cooperation/fuse3.slang @@ -1,5 +1,5 @@ -//TEST(compute, vulkan):COMPARE_COMPUTE_EX():-vk -compute -shaderobj -output-using-type -render-features wave-ops -//TEST(compute):COMPARE_COMPUTE_EX():-dx12 -profile sm_6_5 -use-dxil -compute -shaderobj -output-using-type -render-features wave-ops +//DISABLED_TEST(compute, vulkan):COMPARE_COMPUTE_EX():-vk -compute -shaderobj -output-using-type -render-features wave-ops +//DISABLED_TEST(compute):COMPARE_COMPUTE_EX():-dx12 -profile sm_6_5 -use-dxil -compute -shaderobj -output-using-type -render-features wave-ops // // This test checks whether more than 2 adjacent calls to saturated_cooperation diff --git a/tests/language-feature/saturated-cooperation/simple.slang b/tests/language-feature/saturated-cooperation/simple.slang index d2ea6faed..0a5f78d5b 100644 --- a/tests/language-feature/saturated-cooperation/simple.slang +++ b/tests/language-feature/saturated-cooperation/simple.slang @@ -1,5 +1,5 @@ -//TEST(compute, vulkan):COMPARE_COMPUTE_EX():-vk -compute -shaderobj -output-using-type -render-features wave-ops -//TEST(compute):COMPARE_COMPUTE_EX():-dx12 -profile sm_6_5 -use-dxil -compute -shaderobj -output-using-type -render-features wave-ops +//DISABLED_TEST(compute, vulkan):COMPARE_COMPUTE_EX():-vk -compute -shaderobj -output-using-type -render-features wave-ops +//DISABLED_TEST(compute):COMPARE_COMPUTE_EX():-dx12 -profile sm_6_5 -use-dxil -compute -shaderobj -output-using-type -render-features wave-ops //TEST_INPUT:ubuffer(data=[0 3 2 2], stride=4):out,name=outputBuffer RWStructuredBuffer outputBuffer; diff --git a/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.glsl b/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.glsl index 1da5f4f8a..1897c6467 100644 --- a/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.glsl +++ b/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.glsl @@ -7,13 +7,13 @@ layout(row_major) uniform; layout(row_major) buffer; pervertexNV layout(location = 0) -in vec4 _S1[3]; +in vec4 color_0[3]; layout(location = 0) -out vec4 _S2; +out vec4 result_0; void main() { - _S2 = gl_BaryCoordNV.x * ((_S1)[(0U)]) + gl_BaryCoordNV.y * ((_S1)[(1U)]) + gl_BaryCoordNV.z * ((_S1)[(2U)]); + result_0 = gl_BaryCoordNV.x * ((color_0)[(0U)]) + gl_BaryCoordNV.y * ((color_0)[(1U)]) + gl_BaryCoordNV.z * ((color_0)[(2U)]); return; } diff --git a/tests/pipeline/rasterization/get-attribute-at-vertex.slang.glsl b/tests/pipeline/rasterization/get-attribute-at-vertex.slang.glsl index d8710eed0..5c3ac8286 100644 --- a/tests/pipeline/rasterization/get-attribute-at-vertex.slang.glsl +++ b/tests/pipeline/rasterization/get-attribute-at-vertex.slang.glsl @@ -7,13 +7,13 @@ layout(row_major) uniform; layout(row_major) buffer; pervertexEXT layout(location = 0) -in vec4 _S1[3]; +in vec4 color_0[3]; layout(location = 0) -out vec4 _S2; +out vec4 result_0; void main() { - _S2 = gl_BaryCoordEXT.x * ((_S1)[(0U)]) + gl_BaryCoordEXT.y * ((_S1)[(1U)]) + gl_BaryCoordEXT.z * ((_S1)[(2U)]); + result_0 = gl_BaryCoordEXT.x * ((color_0)[(0U)]) + gl_BaryCoordEXT.y * ((color_0)[(1U)]) + gl_BaryCoordEXT.z * ((color_0)[(2U)]); return; } diff --git a/tests/pipeline/rasterization/mesh/component-write.slang.glsl b/tests/pipeline/rasterization/mesh/component-write.slang.glsl index 143947504..acadf0385 100644 --- a/tests/pipeline/rasterization/mesh/component-write.slang.glsl +++ b/tests/pipeline/rasterization/mesh/component-write.slang.glsl @@ -5,7 +5,7 @@ layout(row_major) buffer; const vec2 positions_0[3] = { vec2(0.0, -0.5), vec2(0.5, 0.5), vec2(-0.5, 0.5) }; const vec3 colors_0[3] = { vec3(1.0, 1.0, 0.0), vec3(0.0, 1.0, 1.0), vec3(1.0, 0.0, 1.0) }; layout(location = 0) -out vec3 _S1[3]; +out vec3 verts_color_0[3]; out gl_MeshPerVertexEXT @@ -26,7 +26,7 @@ void main() if(gl_LocalInvocationIndex < 3U) { gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position = vec4(positions_0[gl_LocalInvocationIndex], 0.0, 1.0); - _S1[gl_LocalInvocationIndex] = colors_0[gl_LocalInvocationIndex]; + verts_color_0[gl_LocalInvocationIndex] = colors_0[gl_LocalInvocationIndex]; } else { diff --git a/tests/pipeline/rasterization/mesh/hlsl-syntax.slang.glsl b/tests/pipeline/rasterization/mesh/hlsl-syntax.slang.glsl index 5e059a8a3..01e29f879 100644 --- a/tests/pipeline/rasterization/mesh/hlsl-syntax.slang.glsl +++ b/tests/pipeline/rasterization/mesh/hlsl-syntax.slang.glsl @@ -5,7 +5,7 @@ layout(row_major) buffer; const vec3 colors_0[3] = { vec3(1.0, 1.0, 0.0), vec3(0.0, 1.0, 1.0), vec3(1.0, 0.0, 1.0) }; const vec2 positions_0[3] = { vec2(0.0, -0.5), vec2(0.5, 0.5), vec2(-0.5, 0.5) }; layout(location = 0) -out vec3 _S1[3]; +out vec3 verts_color_0[3]; out gl_MeshPerVertexEXT { @@ -19,7 +19,7 @@ void foo_0(uint _S2) if(_S2 < 3U) { gl_MeshVerticesEXT[_S2].gl_Position = vec4(positions_0[_S2], 0.0, 1.0); - _S1[_S2] = colors_0[_S2]; + verts_color_0[_S2] = colors_0[_S2]; } else { diff --git a/tests/pipeline/rasterization/mesh/nested-component-write.slang.glsl b/tests/pipeline/rasterization/mesh/nested-component-write.slang.glsl index 4c70955a1..a372a868b 100644 --- a/tests/pipeline/rasterization/mesh/nested-component-write.slang.glsl +++ b/tests/pipeline/rasterization/mesh/nested-component-write.slang.glsl @@ -3,7 +3,7 @@ layout(row_major) uniform; layout(row_major) buffer; layout(location = 0) -out vec3 _S1[3]; +out vec3 verts_foo_bar_baz_color_0[3]; out gl_MeshPerVertexEXT { @@ -20,7 +20,7 @@ void main() if(gl_LocalInvocationIndex < 3U) { gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position = vec4(0.00000000000000000000, 0.00000000000000000000, 0.00000000000000000000, 1.00000000000000000000); - _S1[gl_LocalInvocationIndex] = vec3(1.00000000000000000000, 2.00000000000000000000, 3.00000000000000000000); + verts_foo_bar_baz_color_0[gl_LocalInvocationIndex] = vec3(1.00000000000000000000, 2.00000000000000000000, 3.00000000000000000000); } else { diff --git a/tests/pipeline/rasterization/mesh/passing-outputs.slang b/tests/pipeline/rasterization/mesh/passing-outputs.slang index 321c1179e..20e6abe0b 100644 --- a/tests/pipeline/rasterization/mesh/passing-outputs.slang +++ b/tests/pipeline/rasterization/mesh/passing-outputs.slang @@ -2,7 +2,7 @@ // This tests that writing to individual components of the output struct works -//TEST:CROSS_COMPILE:-target spirv-assembly -entry main -stage mesh -profile glsl_450+spirv_1_4 +//TEST:SIMPLE(filecheck=SPIRV): -target spirv-assembly -entry main -stage mesh -profile glsl_450+spirv_1_4 // DXC is stricter than we are about passing references to individual mesh shader outputs // We could get around this by doing what we do for GLSL, i.e. use a temporary @@ -10,6 +10,8 @@ // after the function call. //TEST_DISABLED:CROSS_COMPILE:-target dxil-assembly -entry main -stage mesh -profile sm_6_6 +// SPIRV: OpEntryPoint MeshEXT %main + const static uint MAX_VERTS = 3; const static uint MAX_PRIMS = 1; diff --git a/tests/pipeline/rasterization/mesh/primitive-output.slang.glsl b/tests/pipeline/rasterization/mesh/primitive-output.slang.glsl index cfe266bec..3623cb8a8 100644 --- a/tests/pipeline/rasterization/mesh/primitive-output.slang.glsl +++ b/tests/pipeline/rasterization/mesh/primitive-output.slang.glsl @@ -7,7 +7,7 @@ const vec3 colors_0[3] = { vec3(1.0, 1.0, 0.0), vec3(0.0, 1.0, 1.0), vec3(1.0, out uvec3 gl_PrimitiveTriangleIndicesEXT[1]; layout(location = 0) -out vec3 _S1[3]; +out vec3 verts_color_0[3]; out gl_MeshPerVertexEXT { @@ -15,7 +15,7 @@ out gl_MeshPerVertexEXT } gl_MeshVerticesEXT[3]; perprimitiveEXT layout(location = 1) -out vec3 _S2[1]; +out vec3 primitives_triangleNormal_0[1]; perprimitiveEXT out gl_MeshPerPrimitiveEXT { @@ -34,7 +34,7 @@ void main() if(gl_LocalInvocationIndex < 3U) { gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position = vec4(positions_0[gl_LocalInvocationIndex], 0.0, 1.0); - _S1[gl_LocalInvocationIndex] = colors_0[gl_LocalInvocationIndex]; + verts_color_0[gl_LocalInvocationIndex] = colors_0[gl_LocalInvocationIndex]; } else { @@ -43,7 +43,7 @@ void main() if(gl_LocalInvocationIndex < 1U) { gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex] = uvec3(0U, 1U, 2U); - _S2[gl_LocalInvocationIndex] = vec3(0.0, 0.0, 1.0); + primitives_triangleNormal_0[gl_LocalInvocationIndex] = vec3(0.0, 0.0, 1.0); gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_PrimitiveID = int(gl_LocalInvocationIndex); gl_MeshPrimitivesEXT[gl_LocalInvocationIndex].gl_CullPrimitiveEXT = false; } diff --git a/tests/spirv/coherent-2.slang b/tests/spirv/coherent-2.slang new file mode 100644 index 000000000..cd7eab8c3 --- /dev/null +++ b/tests/spirv/coherent-2.slang @@ -0,0 +1,15 @@ +// Test that globallycoherent works on arrays of uavs. + +//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage compute -entry main -emit-spirv-directly + +globallycoherent RWByteAddressBuffer buffer[]; + +RWStructuredBuffer output; +[numthreads(4,1,1)] +void main(int tid : SV_DispatchThreadID) +{ + buffer[NonUniformResourceIndex(0)].InterlockedAdd(0, 1); + AllMemoryBarrier(); + output[tid] = buffer[0].Load(0); + // CHECK-DAG: OpDecorate %buffer Coherent +} diff --git a/tests/spirv/coherent.slang b/tests/spirv/coherent.slang new file mode 100644 index 000000000..ba58b713b --- /dev/null +++ b/tests/spirv/coherent.slang @@ -0,0 +1,20 @@ +// Test that globallycoherent works. + +//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage compute -entry main -emit-spirv-directly + +struct S +{ + globallycoherent int member; +} +globallycoherent RWStructuredBuffer buffer; + +RWStructuredBuffer output; +[numthreads(4,1,1)] +void main(int tid : SV_DispatchThreadID) +{ + InterlockedAdd(buffer[0].member, 1); + AllMemoryBarrier(); + output[tid] = buffer[0].member; + // CHECK-DAG: OpMemberDecorate {{.*}} 0 Coherent + // CHECK-DAG: OpDecorate %buffer Coherent +} diff --git a/tests/spirv/varying-out-index.slang b/tests/spirv/varying-out-index.slang new file mode 100644 index 000000000..6448f2266 --- /dev/null +++ b/tests/spirv/varying-out-index.slang @@ -0,0 +1,25 @@ +// Test that explicit binding of varying output works. + +//TEST:SIMPLE(filecheck=CHECK): -stage fragment -entry MainPS -target spirv -emit-spirv-directly + +struct PS_OUTPUT +{ + [[vk::location(0) vk::index(0)]] + float4 vColor : SV_Target0 ; + + [[vk::location(0) vk::index(1)]] + float4 vColor2 : SV_Target1 ; + +}; + +// CHECK: OpDecorate %MainPS_vColor Location 0 +// CHECK: OpDecorate %MainPS_vColor2 Location 0 +// CHECK: OpDecorate %MainPS_vColor2 Index 1 + +PS_OUTPUT MainPS() +{ + PS_OUTPUT output; + output.vColor = float4(1.0f, 0.0f, 0.0f, 1.0f); + output.vColor2 = float4(0.0f, 1.0f, 0.0f, 1.0f); + return output; +} -- cgit v1.2.3