Move dxclib one level up; string handling in DxilRuntimeReflection (#2308)
Move dxclib one level up / out of dxc directory Remove unused member in DxilRuntimeData Change DxilRuntimeReflection handling of strings to be platform independent Fix opt tool (DxcSetThreadMallocOrDefault no longer exist)
This commit is contained in:
Родитель
1de231bd50
Коммит
c1f17ac954
|
@ -572,7 +572,6 @@ public:
|
||||||
|
|
||||||
class DxilRuntimeData {
|
class DxilRuntimeData {
|
||||||
private:
|
private:
|
||||||
uint32_t m_TableCount;
|
|
||||||
StringTableReader m_StringReader;
|
StringTableReader m_StringReader;
|
||||||
IndexTableReader m_IndexTableReader;
|
IndexTableReader m_IndexTableReader;
|
||||||
RawBytesReader m_RawBytesReader;
|
RawBytesReader m_RawBytesReader;
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <cwchar>
|
||||||
|
|
||||||
namespace hlsl {
|
namespace hlsl {
|
||||||
namespace RDAT {
|
namespace RDAT {
|
||||||
|
@ -92,7 +93,7 @@ public:
|
||||||
DxilRuntimeData::DxilRuntimeData() : DxilRuntimeData(nullptr, 0) {}
|
DxilRuntimeData::DxilRuntimeData() : DxilRuntimeData(nullptr, 0) {}
|
||||||
|
|
||||||
DxilRuntimeData::DxilRuntimeData(const void *ptr, size_t size)
|
DxilRuntimeData::DxilRuntimeData(const void *ptr, size_t size)
|
||||||
: m_TableCount(0), m_StringReader(), m_IndexTableReader(), m_RawBytesReader(),
|
: m_StringReader(), m_IndexTableReader(), m_RawBytesReader(),
|
||||||
m_ResourceTableReader(), m_FunctionTableReader(),
|
m_ResourceTableReader(), m_FunctionTableReader(),
|
||||||
m_SubobjectTableReader(), m_Context() {
|
m_SubobjectTableReader(), m_Context() {
|
||||||
m_Context = {&m_StringReader, &m_IndexTableReader, &m_RawBytesReader,
|
m_Context = {&m_StringReader, &m_IndexTableReader, &m_RawBytesReader,
|
||||||
|
@ -311,13 +312,13 @@ public:
|
||||||
|
|
||||||
void DxilRuntimeReflection_impl::AddString(const char *ptr) {
|
void DxilRuntimeReflection_impl::AddString(const char *ptr) {
|
||||||
if (m_StringMap.find(ptr) == m_StringMap.end()) {
|
if (m_StringMap.find(ptr) == m_StringMap.end()) {
|
||||||
int size = ::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, ptr, -1,
|
auto state = std::mbstate_t();
|
||||||
nullptr, 0);
|
size_t size = std::mbsrtowcs(nullptr, &ptr, 0, &state);
|
||||||
if (size != 0) {
|
if (size != static_cast<size_t>(-1)) {
|
||||||
std::unique_ptr<wchar_t[]> pNew(new wchar_t[size]);
|
std::unique_ptr<wchar_t[]> pNew(new wchar_t[size + 1]);
|
||||||
::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, ptr, -1,
|
auto pOldPtr = ptr;
|
||||||
pNew.get(), size);
|
std::mbsrtowcs(pNew.get(), &ptr, size + 1, &state);
|
||||||
m_StringMap[ptr] = std::move(pNew);
|
m_StringMap[pOldPtr] = std::move(pNew);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ add_llvm_external_project(clang-tools-extra extra)
|
||||||
|
|
||||||
# HLSL Change Starts
|
# HLSL Change Starts
|
||||||
add_subdirectory(dxcompiler)
|
add_subdirectory(dxcompiler)
|
||||||
|
add_subdirectory(dxclib)
|
||||||
add_subdirectory(dxc)
|
add_subdirectory(dxc)
|
||||||
|
|
||||||
# These targets can currently only be built on Windows.
|
# These targets can currently only be built on Windows.
|
||||||
|
|
|
@ -24,6 +24,7 @@ add_clang_executable(dxc
|
||||||
target_link_libraries(dxc
|
target_link_libraries(dxc
|
||||||
dxclib
|
dxclib
|
||||||
dxcompiler
|
dxcompiler
|
||||||
|
dxclib
|
||||||
)
|
)
|
||||||
|
|
||||||
if(ENABLE_SPIRV_CODEGEN)
|
if(ENABLE_SPIRV_CODEGEN)
|
||||||
|
@ -37,6 +38,8 @@ if (WIN32)
|
||||||
include_directories(AFTER ${DIASDK_INCLUDE_DIRS})
|
include_directories(AFTER ${DIASDK_INCLUDE_DIRS})
|
||||||
endif (WIN32)
|
endif (WIN32)
|
||||||
|
|
||||||
|
include_directories(${LLVM_SOURCE_DIR}/tools/clang/tools)
|
||||||
|
|
||||||
add_dependencies(dxc dxclib dxcompiler)
|
add_dependencies(dxc dxclib dxcompiler)
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
|
@ -51,5 +54,3 @@ endif()
|
||||||
install(TARGETS dxc
|
install(TARGETS dxc
|
||||||
RUNTIME DESTINATION bin)
|
RUNTIME DESTINATION bin)
|
||||||
|
|
||||||
add_subdirectory(dxclib)
|
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,16 @@ if (WIN32)
|
||||||
find_package(DiaSDK REQUIRED) # Used for constants and declarations.
|
find_package(DiaSDK REQUIRED) # Used for constants and declarations.
|
||||||
endif (WIN32)
|
endif (WIN32)
|
||||||
|
|
||||||
|
set( LLVM_LINK_COMPONENTS
|
||||||
|
${LLVM_TARGETS_TO_BUILD}
|
||||||
|
dxcsupport
|
||||||
|
DXIL
|
||||||
|
DxilContainer
|
||||||
|
HLSL
|
||||||
|
Option # option library
|
||||||
|
Support # just for assert and raw streams
|
||||||
|
)
|
||||||
|
|
||||||
add_clang_library(dxclib
|
add_clang_library(dxclib
|
||||||
dxc.cpp
|
dxc.cpp
|
||||||
)
|
)
|
||||||
|
@ -18,4 +28,4 @@ if (WIN32)
|
||||||
include_directories(AFTER ${DIASDK_INCLUDE_DIRS})
|
include_directories(AFTER ${DIASDK_INCLUDE_DIRS})
|
||||||
endif (WIN32)
|
endif (WIN32)
|
||||||
|
|
||||||
add_dependencies(dxclib TablegenHLSLOptions)
|
add_dependencies(dxclib TablegenHLSLOptions dxcompiler)
|
|
@ -305,7 +305,7 @@ int __cdecl main(int argc, char **argv) {
|
||||||
return 1;
|
return 1;
|
||||||
llvm::sys::fs::AutoCleanupPerThreadFileSystem auto_cleanup_fs;
|
llvm::sys::fs::AutoCleanupPerThreadFileSystem auto_cleanup_fs;
|
||||||
if (FAILED(DxcInitThreadMalloc())) return 1;
|
if (FAILED(DxcInitThreadMalloc())) return 1;
|
||||||
DxcSetThreadMallocOrDefault(nullptr);
|
DxcSetThreadMallocToDefault();
|
||||||
llvm::sys::fs::MSFileSystem* msfPtr;
|
llvm::sys::fs::MSFileSystem* msfPtr;
|
||||||
if (FAILED(CreateMSFileSystemForDisk(&msfPtr))) return 1;
|
if (FAILED(CreateMSFileSystemForDisk(&msfPtr))) return 1;
|
||||||
std::unique_ptr<llvm::sys::fs::MSFileSystem> msf(msfPtr);
|
std::unique_ptr<llvm::sys::fs::MSFileSystem> msf(msfPtr);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче