summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-09-13 09:48:32 -0700
committerGitHub <noreply@github.com>2023-09-13 09:48:32 -0700
commitd2466a602774fcaec063e2f8cdbf86fd5e160a21 (patch)
tree13d453cbf79c51ddba4131453da89055fe9740af /source
parentc0a77c360436c4f1ec4d284e331063c35bdf95ad (diff)
Add all RayQuery SPIRV Intrinsics. (#3204)
* Add all RayQuery SPIRV Intrinsics. * Fix * Fix. * fix. * Fix. * Fix. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source')
-rw-r--r--source/compiler-core/slang-spirv-dis-compiler.cpp61
-rw-r--r--source/core/slang-stream.cpp28
-rw-r--r--source/core/slang-stream.h3
-rw-r--r--source/core/windows/slang-win-process.cpp6
-rw-r--r--source/slang/hlsl.meta.slang398
-rw-r--r--source/slang/slang-artifact-output-util.cpp1
-rw-r--r--source/slang/slang-ir-spirv-legalize.cpp4
-rw-r--r--source/slang/slang-language-server.cpp3
-rw-r--r--source/slang/slang-lookup.cpp4
9 files changed, 273 insertions, 235 deletions
diff --git a/source/compiler-core/slang-spirv-dis-compiler.cpp b/source/compiler-core/slang-spirv-dis-compiler.cpp
index 0e484c7c5..9b40254ce 100644
--- a/source/compiler-core/slang-spirv-dis-compiler.cpp
+++ b/source/compiler-core/slang-spirv-dis-compiler.cpp
@@ -1,5 +1,4 @@
#include "slang-spirv-dis-compiler.h"
-
#include "../core/slang-common.h"
#include "../core/slang-string-util.h"
#include "../core/slang-string.h"
@@ -7,7 +6,6 @@
#include "slang-artifact-representation.h"
#include "slang-artifact-util.h"
#include "slang-artifact-representation-impl.h"
-
namespace Slang
{
@@ -18,7 +16,6 @@ SlangResult SPIRVDisDownstreamCompilerUtil::locateCompilers(
{
// TODO: We could check that the compiler is actually present in PATH (or
// explicitly given)
-
ComPtr<IDownstreamCompiler> com(
new SPIRVDisDownstreamCompiler(DownstreamCompilerDesc(SLANG_PASS_THROUGH_SPIRV_DIS)));
set->addCompiler(com);
@@ -43,54 +40,58 @@ SlangResult SLANG_MCALL SPIRVDisDownstreamCompiler::convert(
ISlangBlob* fromBlob;
SLANG_RETURN_ON_FAIL(from->loadBlob(ArtifactKeep::No, &fromBlob));
- ComPtr<IOSFileArtifactRepresentation> fromFile;
- SLANG_RETURN_ON_FAIL(from->requireFile(ArtifactKeep::No, fromFile.writeRef()));
-
- String toFile;
- File::generateTemporary(UnownedStringSlice("spv-asm"), toFile);
-
// Set up our process
CommandLine commandLine;
commandLine.m_executableLocation.setName("spirv-dis");
commandLine.addArg("--comment");
- commandLine.addArg(fromFile->getPath());
- commandLine.addArg("-o");
- commandLine.addArg(toFile);
+
RefPtr<Process> p;
SLANG_RETURN_ON_FAIL(Process::create(commandLine, 0, p));
+
+ auto inputStream = p->getStream(StdStreamType::In);
+ if (!inputStream)
+ return SLANG_FAIL;
+
+ auto outputStream = p->getStream(StdStreamType::Out);
+ List<uint8_t> outBytes;
const auto err = p->getStream(StdStreamType::ErrorOut);
+ List<Byte> errData;
+
+ SLANG_RETURN_ON_FAIL(StreamUtil::readAndWrite(
+ inputStream,
+ ArrayView<Byte>((Byte*)fromBlob->getBufferPointer(), (Index)fromBlob->getBufferSize()),
+ outputStream,
+ outBytes,
+ err,
+ errData));
// Wait for it to finish
if(!p->waitForTermination(1000))
return SLANG_FAIL;
- // TODO: allow inheriting stderr in Process
- List<Byte> errData;
- SLANG_RETURN_ON_FAIL(StreamUtil::readAll(err, 0, errData));
- fwrite(errData.getBuffer(), errData.getCount(), 1, stderr);
+ if (errData.getCount())
+ fwrite(errData.getBuffer(), 1, (size_t)errData.getCount(), stderr);
+ StringBuilder sbOutput;
+ List<UnownedStringSlice> lines;
+ StringUtil::calcLines(StringUtil::trimEndOfLine(UnownedStringSlice((const char*)outBytes.getBuffer())), lines);
+ for (auto line : lines)
+ {
+ sbOutput << StringUtil::trimEndOfLine(line) << "\n";
+ }
// If spirv-dis failed, we fail
const auto ret = p->getReturnValue();
if(ret != 0)
return SLANG_FAIL;
- // Normalize line endings
- String outContents;
- SLANG_RETURN_ON_FAIL(File::readAllText(toFile, outContents));
- StringBuilder outBuilder;
- StringUtil::appendStandardLines(outContents.getUnownedSlice(), outBuilder);
- SLANG_RETURN_ON_FAIL(File::writeAllBytes(toFile, outBuilder.getBuffer(), outBuilder.getLength()));
-
// Return as a file artifact
- auto fileRep = OSFileArtifactRepresentation::create(
- IOSFileArtifactRepresentation::Kind::Owned,
- toFile.getUnownedSlice(),
- nullptr
- );
+
+ auto disassemblyBlob = StringBlob::moveCreate(sbOutput);
+
auto artifact = ArtifactUtil::createArtifact(to);
- artifact->addRepresentation(fileRep.detach());
- *outArtifact = artifact.detach();
+ artifact->addRepresentationUnknown(disassemblyBlob);
+ *outArtifact = artifact.detach();
return SLANG_OK;
}
diff --git a/source/core/slang-stream.cpp b/source/core/slang-stream.cpp
index 4b5d92228..6507c2e56 100644
--- a/source/core/slang-stream.cpp
+++ b/source/core/slang-stream.cpp
@@ -2,6 +2,7 @@
#ifdef _WIN32
#include <share.h>
#endif
+#include <thread>
#include "slang-io.h"
#include "slang-process.h"
@@ -587,6 +588,33 @@ SlangResult BufferedReadStream::readUntilContains(size_t size)
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!! StreamUtil !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+SlangResult StreamUtil::readAndWrite(
+ Stream* writeStream,
+ ArrayView<Byte> bytesToWrite,
+ Stream* readStream, List<Byte>& outReadBytes,
+ Stream* errStream,
+ List<Byte>& outErrBytes)
+{
+ std::thread writeThread([&]()
+ {
+ writeStream->write(bytesToWrite.getBuffer(), (size_t)bytesToWrite.getCount());
+ writeStream->close();
+ });
+ SlangResult readResult = SLANG_OK;
+ std::thread readThread([&]()
+ {
+ readResult = readAll(readStream, 1024, outReadBytes);
+ });
+ std::thread readErrThread([&]()
+ {
+ readAll(errStream, 1024, outErrBytes);
+ });
+ writeThread.join();
+ readThread.join();
+ readErrThread.join();
+ return readResult;
+}
+
/* static */SlangResult StreamUtil::readAll(Stream* stream, size_t readSize, List<Byte>& ioBytes)
{
while (!stream->isEnd())
diff --git a/source/core/slang-stream.h b/source/core/slang-stream.h
index 388b178c9..9f405dbb0 100644
--- a/source/core/slang-stream.h
+++ b/source/core/slang-stream.h
@@ -253,6 +253,9 @@ enum class StreamBufferStyle
struct StreamUtil
{
+ // Write inputs to writeStream while simultaneously read from readStream and errStream.
+ static SlangResult readAndWrite(Stream* writeStream, ArrayView<Byte> bytesToWrite, Stream* readStream, List<Byte>& outReadBytes, Stream* errStream, List<Byte>& outErrBytes);
+
/// Appends all bytes that can be read from stream into bytes
static SlangResult readAll(Stream* stream, size_t readSize, List<Byte>& ioBytes);
diff --git a/source/core/windows/slang-win-process.cpp b/source/core/windows/slang-win-process.cpp
index 38f733015..8b41393ae 100644
--- a/source/core/windows/slang-win-process.cpp
+++ b/source/core/windows/slang-win-process.cpp
@@ -98,10 +98,9 @@ protected:
FileAccess m_access = FileAccess::None;
WinHandle m_streamHandle;
bool m_isOwned;
- bool m_isPipe;
+ bool m_isPipe;
};
-
class WinProcess : public Process
{
public:
@@ -526,12 +525,13 @@ void WinProcess::kill(int32_t returnCode)
}
RefPtr<Stream> streams[Index(StdStreamType::CountOf)];
+
if (childStdErrRead)
streams[Index(StdStreamType::ErrorOut)] = new WinPipeStream(childStdErrRead.detach(), FileAccess::Read);
streams[Index(StdStreamType::Out)] = new WinPipeStream(childStdOutRead.detach(), FileAccess::Read);
streams[Index(StdStreamType::In)] = new WinPipeStream(childStdInWrite.detach(), FileAccess::Write);
-
outProcess = new WinProcess(processHandle.detach(), streams[0].readRef());
+
return SLANG_OK;
}
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang
index dce44c9cc..c04a88923 100644
--- a/source/slang/hlsl.meta.slang
+++ b/source/slang/hlsl.meta.slang
@@ -7874,6 +7874,36 @@ struct RayQuery <let rayFlagsGeneric : RAY_FLAG = RAY_FLAG_NONE>
}
}
+ // Commit the current non-opaque triangle hit.
+ __glsl_extension(GL_EXT_ray_query)
+ __glsl_version(460)
+ [__NoSideEffect]
+ [mutating]
+ void CommitNonOpaqueTriangleHit()
+ {
+ __target_switch
+ {
+ case hlsl: __intrinsic_asm ".CommitNonOpaqueTriangleHit";
+ case glsl: __intrinsic_asm "rayQueryConfirmIntersectionEXT";
+ case spirv: spirv_asm { OpRayQueryConfirmIntersectionKHR &this };
+ }
+ }
+
+ // Commit the current procedural primitive hit, with hit time `t`.
+ __glsl_extension(GL_EXT_ray_query)
+ __glsl_version(460)
+ [__NoSideEffect]
+ [mutating]
+ void CommitProceduralPrimitiveHit(float t)
+ {
+ __target_switch
+ {
+ case hlsl: __intrinsic_asm ".CommitProceduralPrimitiveHit";
+ case glsl: __intrinsic_asm "rayQueryGenerateIntersectionEXT";
+ case spirv: spirv_asm { OpRayQueryGenerateIntersectionKHR &this $t };
+ }
+ }
+
// Get the type of candidate hit being considered.
//
// The ray query coroutine will suspend when it encounters
@@ -7885,7 +7915,7 @@ struct RayQuery <let rayFlagsGeneric : RAY_FLAG = RAY_FLAG_NONE>
//
__glsl_extension(GL_EXT_ray_query)
__glsl_version(460)
- [__readNone]
+ [__NoSideEffect]
CANDIDATE_TYPE CandidateType()
{
__target_switch
@@ -7900,125 +7930,10 @@ struct RayQuery <let rayFlagsGeneric : RAY_FLAG = RAY_FLAG_NONE>
}
}
- // Access properties of a candidate hit.
-
- __target_intrinsic(glsl, "transpose(rayQueryGetIntersectionObjectToWorldEXT($0, false))")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- float3x4 CandidateObjectToWorld3x4();
-
- __target_intrinsic(glsl, "rayQueryGetIntersectionObjectToWorldEXT($0, false)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- float4x3 CandidateObjectToWorld4x3();
-
- __target_intrinsic(glsl, "transpose(rayQueryGetIntersectionWorldToObjectEXT($0, false))")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- float3x4 CandidateWorldToObject3x4();
-
- __target_intrinsic(glsl, "rayQueryGetIntersectionWorldToObjectEXT($0, false)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- float4x3 CandidateWorldToObject4x3();
-
- __target_intrinsic(glsl, "rayQueryGetIntersectionInstanceIdEXT($0, false)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- uint CandidateInstanceIndex();
-
- __target_intrinsic(glsl, "rayQueryGetIntersectionInstanceCustomIndexEXT($0, false)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- uint CandidateInstanceID();
-
- __target_intrinsic(glsl, "rayQueryGetIntersectionGeometryIndexEXT($0, false)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- uint CandidateGeometryIndex();
-
- __target_intrinsic(glsl, "rayQueryGetIntersectionPrimitiveIndexEXT($0, false)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- uint CandidatePrimitiveIndex();
-
- __target_intrinsic(glsl, "rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT($0, false)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- uint CandidateInstanceContributionToHitGroupIndex();
-
- // Access properties of the ray being traced
- // in the object space of a candidate hit.
-
- __target_intrinsic(glsl, "rayQueryGetIntersectionObjectRayOriginEXT($0, false)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- float3 CandidateObjectRayOrigin();
-
- __target_intrinsic(glsl, "rayQueryGetIntersectionObjectRayDirectionEXT($0, false)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- float3 CandidateObjectRayDirection();
-
- // Access properties of a candidate procedural primitive hit.
-
- __target_intrinsic(glsl, "rayQueryGetIntersectionCandidateAABBOpaqueEXT($0, false)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- bool CandidateProceduralPrimitiveNonOpaque();
-
- // Access properties of a candidate non-opaque triangle hit.
-
- __target_intrinsic(glsl, "rayQueryGetIntersectionFrontFaceEXT($0, false)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- bool CandidateTriangleFrontFace();
-
- __target_intrinsic(glsl, "rayQueryGetIntersectionBarycentricsEXT($0, false)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- float2 CandidateTriangleBarycentrics();
-
- __target_intrinsic(glsl, "rayQueryGetIntersectionTEXT($0, false)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- float CandidateTriangleRayT();
-
- // Commit the current non-opaque triangle hit.
- __target_intrinsic(glsl, rayQueryConfirmIntersectionEXT)
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__NoSideEffect]
- [mutating]
- void CommitNonOpaqueTriangleHit();
-
- // Commit the current procedural primitive hit, with hit time `t`.
- __target_intrinsic(glsl, rayQueryGenerateIntersectionEXT)
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__NoSideEffect]
- [mutating]
- void CommitProceduralPrimitiveHit(float t);
-
// Get the status of the committed (closest) hit, if any.
__glsl_extension(GL_EXT_ray_query)
__glsl_version(460)
- [__readNone]
+ [__NoSideEffect]
COMMITTED_STATUS CommittedStatus()
{
__target_switch
@@ -8034,134 +7949,221 @@ struct RayQuery <let rayFlagsGeneric : RAY_FLAG = RAY_FLAG_NONE>
}
}
- // Access properties of the committed hit.
- //
- __target_intrinsic(glsl, "transpose(rayQueryGetIntersectionObjectToWorldEXT($0, true))")
__glsl_extension(GL_EXT_ray_query)
__glsl_version(460)
- [__readNone]
- float3x4 CommittedObjectToWorld3x4();
-
- __target_intrinsic(glsl, "rayQueryGetIntersectionObjectToWorldEXT($0, true)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- float4x3 CommittedObjectToWorld4x3();
-
- __target_intrinsic(glsl, "transpose(rayQueryGetIntersectionWorldToObjectEXT($0, true))")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- float3x4 CommittedWorldToObject3x4();
+ [__NoSideEffect]
+ bool CandidateProceduralPrimitiveNonOpaque()
+ {
+ __target_switch
+ {
+ case hlsl: __intrinsic_asm ".CandidateProceduralPrimitiveNonOpaque";
+ case glsl: __intrinsic_asm "(!rayQueryGetIntersectionCandidateAABBOpaqueEXT($0, false))";
+ case spirv:
+ uint iCandidateOrCommitted = 0;
+ return spirv_asm
+ {
+ %rr:$$bool = OpRayQueryGetIntersectionCandidateAABBOpaqueKHR &this $iCandidateOrCommitted;
+ result:$$bool = OpLogicalNot %rr;
+ };
+ }
+ }
- __target_intrinsic(glsl, "rayQueryGetIntersectionWorldToObjectEXT($0, true)")
__glsl_extension(GL_EXT_ray_query)
__glsl_version(460)
- [__readNone]
- float4x3 CommittedWorldToObject4x3();
-
+ [__NoSideEffect]
+ float CandidateTriangleRayT()
+ {
+ __target_switch
+ {
+ case hlsl: __intrinsic_asm ".CandidateTriangleRayT";
+ case glsl: __intrinsic_asm "rayQueryGetIntersectionTEXT($0, false)";
+ case spirv:
+ uint iCandidateOrCommitted = 0;
+ return spirv_asm
+ {
+ result:$$float = OpRayQueryGetIntersectionTKHR &this $iCandidateOrCommitted;
+ };
+ }
+ }
__glsl_extension(GL_EXT_ray_query)
__glsl_version(460)
- [__readNone]
+ [__NoSideEffect]
float CommittedRayT()
{
__target_switch
{
- case glsl: __intrinsic_asm "rayQueryGetIntersectionTEXT($0, true)";
case hlsl: __intrinsic_asm ".CommittedRayT";
+ case glsl: __intrinsic_asm "rayQueryGetIntersectionTEXT($0, true)";
case spirv:
- uint RayQueryCommittedIntersectionKHR = 1;
+ uint iCandidateOrCommitted = 1;
return spirv_asm
{
- result:$$float = OpRayQueryGetIntersectionTKHR &this $RayQueryCommittedIntersectionKHR
+ result:$$float = OpRayQueryGetIntersectionTKHR &this $iCandidateOrCommitted;
};
}
}
- __target_intrinsic(glsl, "rayQueryGetIntersectionInstanceIdEXT($0, true)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- uint CommittedInstanceIndex();
-
- __target_intrinsic(glsl, "rayQueryGetIntersectionInstanceCustomIndexEXT($0, true)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- uint CommittedInstanceID();
-
- __target_intrinsic(glsl, "rayQueryGetIntersectionGeometryIndexEXT($0, true)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- uint CommittedGeometryIndex();
-
- __target_intrinsic(glsl, "rayQueryGetIntersectionPrimitiveIndexEXT($0, true)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- uint CommittedPrimitiveIndex();
+${{{{
+ const char* kCandidateCommitted[] = {"Candidate", "Committed"};
- __target_intrinsic(glsl, "rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT($0, true)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- uint CommittedInstanceContributionToHitGroupIndex();
+ // Access Candidate and Committed Matrices.
+ for (uint32_t candidateOrCommitted = 0; candidateOrCommitted < 2; candidateOrCommitted++)
+ {
+ auto ccName = kCandidateCommitted[candidateOrCommitted];
+ auto ccTF = candidateOrCommitted == 0 ? "false" : "true";
+}}}}
- // Access properties of the ray being traced
- // in the object space of a committed hit.
+ // CandidateObjectToWorld3x4, CandidateWorldToObject4x3
+ // CommittedObjectToWorld3x4, CommittedObjectToWorld4x3
+ ${{{{
+ const char* kRayQueryMatrixNames[] = {"ObjectToWorld", "WorldToObject"};
+ for (auto matName : kRayQueryMatrixNames) {
+ }}}}
- __target_intrinsic(glsl, "rayQueryGetIntersectionObjectRayOriginEXT($0, true)")
__glsl_extension(GL_EXT_ray_query)
__glsl_version(460)
- [__readNone]
- float3 CommittedObjectRayOrigin();
+ [__NoSideEffect]
+ float3x4 $(ccName)$(matName)3x4()
+ {
+ __target_switch
+ {
+ case glsl: __intrinsic_asm "transpose(rayQueryGetIntersection$(matName)EXT($0, $(ccTF)))";
+ case hlsl: __intrinsic_asm ".$(ccName)$(matName)3x4";
+ case spirv:
+ uint iCandidateOrCommitted = $(candidateOrCommitted);
+ return spirv_asm {
+ %m:$$float4x3 = OpRayQueryGetIntersection$(matName)KHR &this $iCandidateOrCommitted;
+ result:$$float3x4 = OpTranspose %m;
+ };
+ }
+ }
- __target_intrinsic(glsl, "rayQueryGetIntersectionObjectRayDirectionEXT($0, true)")
__glsl_extension(GL_EXT_ray_query)
__glsl_version(460)
[__readNone]
- float3 CommittedObjectRayDirection();
+ float4x3 $(ccName)$(matName)4x3()
+ {
+ __target_switch
+ {
+ case glsl: __intrinsic_asm "rayQueryGetIntersection$(matName)EXT($0, $(ccTF))";
+ case hlsl: __intrinsic_asm ".$(ccName)$(matName)4x3";
+ case spirv:
+ uint iCandidateOrCommitted = $(candidateOrCommitted);
+ return spirv_asm {
+ result:$$float4x3 = OpRayQueryGetIntersection$(matName)KHR &this $iCandidateOrCommitted;
+ };
+ }
+ }
- // Access properties of a committed triangle hit.
+${{{{
+ } // ObjectToWorld/WorldToObject.
- __target_intrinsic(glsl, "rayQueryGetIntersectionFrontFaceEXT($0, true)")
- __glsl_extension(GL_EXT_ray_query)
- __glsl_version(460)
- [__readNone]
- bool CommittedTriangleFrontFace();
+ // Access Candidate and Committed properties.
+ struct RayQueryMethodEntry
+ {
+ const char* type;
+ const char* hlslName;
+ const char* glslName;
+ };
+ const RayQueryMethodEntry rayQueryMethods[] = {
+ {"uint", "InstanceIndex", "InstanceId"},
+ {"uint", "InstanceID", "InstanceCustomIndex"},
+ {"uint", "PrimitiveIndex", "PrimitiveIndex"},
+ {"uint", "InstanceContributionToHitGroupIndex", "InstanceShaderBindingTableRecordOffset"},
+ {"float3", "ObjectRayOrigin", "ObjectRayOrigin"},
+ {"float3", "ObjectRayDirection", "ObjectRayDirection"},
+ {"bool", "TriangleFrontFace", "FrontFace"},
+ {"float2", "TriangleBarycentrics", "Barycentrics"},
+ };
+ for (auto method : rayQueryMethods) {
+}}}}
- __target_intrinsic(glsl, "rayQueryGetIntersectionBarycentricsEXT($0, true)")
__glsl_extension(GL_EXT_ray_query)
__glsl_version(460)
- [__readNone]
- float2 CommittedTriangleBarycentrics();
+ [__NoSideEffect]
+ $(method.type) $(ccName)$(method.hlslName)()
+ {
+ __target_switch
+ {
+ case hlsl: __intrinsic_asm ".$(ccName)$(method.hlslName)";
+ case glsl: __intrinsic_asm "rayQueryGetIntersection$(method.glslName)EXT($0, $(ccTF))";
+ case spirv:
+ uint iCandidateOrCommitted = $(candidateOrCommitted);
+ return spirv_asm {
+ result:$$$(method.type) = OpRayQueryGetIntersection$(method.glslName)KHR &this $iCandidateOrCommitted;
+ };
+ }
+ }
+${{{{
+ } // Candidate/Committed properties.
+ } // for ("Candidate", "Committed")
+}}}}
// Access properties of the ray being traced.
- __target_intrinsic(glsl, rayQueryGetRayFlagsEXT)
__glsl_extension(GL_EXT_ray_query)
__glsl_version(460)
- [__readNone]
- uint RayFlags();
+ [__NoSideEffect]
+ uint RayFlags()
+ {
+ __target_switch
+ {
+ case hlsl: __intrinsic_asm ".RayFlags";
+ case glsl: __intrinsic_asm "rayQueryGetRayFlagsEXT";
+ case spirv:
+ return spirv_asm {
+ result:$$uint = OpRayQueryGetRayFlagsKHR &this;
+ };
+ }
+ }
- __target_intrinsic(glsl, rayQueryGetWorldRayOriginEXT)
__glsl_extension(GL_EXT_ray_query)
__glsl_version(460)
- [__readNone]
- float3 WorldRayOrigin();
+ [__NoSideEffect]
+ float3 WorldRayOrigin()
+ {
+ __target_switch
+ {
+ case hlsl: __intrinsic_asm ".WorldRayOrigin";
+ case glsl: __intrinsic_asm "rayQueryGetWorldRayOriginEXT";
+ case spirv:
+ return spirv_asm {
+ result:$$float3 = OpRayQueryGetWorldRayOriginKHR &this;
+ };
+ }
+ }
- __target_intrinsic(glsl, rayQueryGetWorldRayDirectionEXT)
__glsl_extension(GL_EXT_ray_query)
__glsl_version(460)
- [__readNone]
- float3 WorldRayDirection();
+ [__NoSideEffect]
+ float3 WorldRayDirection()
+ {
+ __target_switch
+ {
+ case hlsl: __intrinsic_asm ".WorldRayDirection";
+ case glsl: __intrinsic_asm "rayQueryGetWorldRayDirectionEXT";
+ case spirv:
+ return spirv_asm {
+ result:$$float3 = OpRayQueryGetWorldRayDirectionKHR &this;
+ };
+ }
+ }
- __target_intrinsic(glsl, rayQueryGetRayTMinEXT)
__glsl_extension(GL_EXT_ray_query)
__glsl_version(460)
- [__readNone]
- float RayTMin();
+ [__NoSideEffect]
+ float RayTMin()
+ {
+ __target_switch
+ {
+ case hlsl: __intrinsic_asm ".RayTMin";
+ case glsl: __intrinsic_asm "rayQueryGetRayTMinEXT";
+ case spirv:
+ return spirv_asm {
+ result:$$float = OpRayQueryGetRayTMinKHR &this;
+ };
+ }
+ };
}
//
diff --git a/source/slang/slang-artifact-output-util.cpp b/source/slang/slang-artifact-output-util.cpp
index 32aff9f43..2c560e236 100644
--- a/source/slang/slang-artifact-output-util.cpp
+++ b/source/slang/slang-artifact-output-util.cpp
@@ -75,7 +75,6 @@ SlangResult ArtifactOutputUtil::maybeDisassemble(Session* session, IArtifact* ar
auto toDesc = desc;
toDesc.kind = ArtifactKind::Assembly;
-
// If this likes a playsible disassebly conversion
if (ArtifactDescUtil::isDisassembly(desc, toDesc))
{
diff --git a/source/slang/slang-ir-spirv-legalize.cpp b/source/slang/slang-ir-spirv-legalize.cpp
index 8d785bceb..54cacf4a6 100644
--- a/source/slang/slang-ir-spirv-legalize.cpp
+++ b/source/slang/slang-ir-spirv-legalize.cpp
@@ -202,6 +202,8 @@ struct SPIRVLegalizationContext : public SourceEmitterBase
i->removeAndDeallocate();
}
+ // Returns true if the given type that should be decorated as in `UniformConstant` address space.
+ // These are typically opaque resource handles that can't be marked as `Uniform`.
bool isSpirvUniformConstantType(IRType* type)
{
if (as<IRTextureTypeBase>(type))
@@ -250,7 +252,7 @@ struct SPIRVLegalizationContext : public SourceEmitterBase
}
}
- // Textures and Samplers can't be in Uniform for Vulkan, if they are
+ // Opaque resource handles can't be in Uniform for Vulkan, if they are
// placed here then put them in UniformConstant instead
if (storageClass == SpvStorageClassUniform
&& isSpirvUniformConstantType(inst->getDataType()))
diff --git a/source/slang/slang-language-server.cpp b/source/slang/slang-language-server.cpp
index 54da4120c..ad88ab5ac 100644
--- a/source/slang/slang-language-server.cpp
+++ b/source/slang/slang-language-server.cpp
@@ -910,6 +910,8 @@ SlangResult LanguageServer::completion(
// Always create a new workspace version for the completion request since we
// will use a modified source.
auto version = m_workspace->createVersionForCompletion();
+ SLANG_AST_BUILDER_RAII(version->linkage->getASTBuilder());
+
auto moduleName = getMangledNameFromNameString(canonicalPath.getUnownedSlice());
version->linkage->contentAssistInfo.cursorLine = utf8Line;
version->linkage->contentAssistInfo.cursorCol = utf8Col;
@@ -1007,6 +1009,7 @@ SlangResult LanguageServer::completionResolve(
m_connection->sendResult(&resolvedItem, responseId);
return SLANG_OK;
}
+ SLANG_AST_BUILDER_RAII(version->linkage->getASTBuilder());
auto& candidateItems = version->linkage->contentAssistInfo.completionSuggestions.candidateItems;
if (itemId >= 0 && itemId < candidateItems.getCount())
{
diff --git a/source/slang/slang-lookup.cpp b/source/slang/slang-lookup.cpp
index 89d3380e4..b32236019 100644
--- a/source/slang/slang-lookup.cpp
+++ b/source/slang/slang-lookup.cpp
@@ -372,7 +372,7 @@ static void _lookUpMembersInSuperTypeDeclImpl(
BreadcrumbInfo* inBreadcrumbs)
{
auto semantics = request.semantics;
- if (!as<InterfaceDecl>(declRef.getDecl()) && name->text == "This")
+ if (!as<InterfaceDecl>(declRef.getDecl()) && getText(name) == "This")
{
// If we are looking for `This` in anything other than an InterfaceDecl,
// we just need to return the declRef itself.
@@ -471,7 +471,7 @@ static void _lookUpMembersInSuperTypeDeclImpl(
parentDeclRef = _maybeSpecializeSuperTypeDeclRef(
astBuilder, containerDeclRef, facet->getType(), facet->subtypeWitness)
.as<ContainerDecl>();
- if (as<ThisTypeDecl>(parentDeclRef.getDecl()) && name->text == "This")
+ if (as<ThisTypeDecl>(parentDeclRef.getDecl()) && getText(name) == "This")
{
// If we are going looking for `This` in a `ThisType`, we just need to return the declRef itself.
AddToLookupResult(ioResult, CreateLookupResultItem(parentDeclRef, inBreadcrumbs));