summaryrefslogtreecommitdiffstats
path: root/source/core
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/core
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/core')
-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
3 files changed, 34 insertions, 3 deletions
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;
}