Граф коммитов

17 Коммитов

Автор SHA1 Сообщение Дата
Antonio Maiorano 9419b9b1c7
Fix UBSAN error in DxilRootSignatureSerializer (#5795)
Fix UBSAN error:
```
lib/DxilRootSignature/DxilRootSignatureSerializer.cpp:134:5: runtime error: store to misaligned address 0x7fff812daf5f for type 'unsigned int', which requires 4 byte alignment
```

Use memcpy to write to unaligned address.

Fixes 63 of these reported from running check-all.
2023-09-29 10:28:05 -04:00
Chris B 37ed613864
[NFC] Clang-format DXC sources (#5602)
This change applies clang-format to all of the sources added in DXC that
were not part of the original LLVM/Clang 3.7 release when DXC forked.
This provides consistent code formatting across the codebase.

Fixes #5591.
2023-09-19 07:49:22 -05:00
Chris B 3266a87f9a
[NFC] Remove SAL annotations from internal APIs (#5639)
We don't keep these annotations up to date or rely on them, so to
simplify our platform layering and ease code formatting this change
removes all the SAL annotations from internal APIs. This change also
replaces most `_Analysis_Assme_(...)` annotations with `assert(...)`.

One `_Analysis_Assume_` in ParseDecl.cpp needed to be updated because it
was incorrect. The code was `_Analysis_Assume_(assert(name.size() >
sizeof("space"));`. When converted to an `assert` it fired in our test
suite because the sizeof a string literal includes the null terminator,
but the size of a StringRef does not.

A few of the `_Analysis_Assume_` annotations were removed because they
didn't make sense (like the ones inside the `DXASSERT` implementation,
and a few others were removed to avoid introducing additional header or
linkage dependencies.

This change does not introduce any functional or behavioral changes.
2023-09-14 08:59:49 -05:00
Joshua Batista 071972d7df
Remove some warnings from GCC when building DXC (#5262)
* remove warnings on dxc

* address feedback

* remove removed functions' declarations

* get rid of another unused function

* use maybe_unused instead of if 0 when removing unused functions

* address commenting issues

* Revert "use maybe_unused instead of if 0 when removing unused functions" because c++17 extensions aren't enabled

This reverts commit 3a00d8eb84.

* remove incorrect scope
2023-06-02 13:10:20 -07:00
Chris B 2168dcb4fb
Clean up and rework DXIL library depencencies (#4877)
* Clean up and rework DXIL library depencencies

This change reworks the dependency specifications for the DXIL*
libraries. Many of these libraries had over and under specified
dependencies.

This also collapses the DxilRDATBuidlder into the DxilContainer library
to remove the cyclic dependency between the two libraries.

* Break assert dependency between DXIL and Analysis

In assert builds the DXILModule constructor was creating forced bindings
to debugging methods that are often used from the debugger. This forced
binding is useful, but doesn't need to live in the DXIL library.

To break the dependency I've moved the code into Analysis. I've also
made that code only included when building with MSVC. When using other
compilers `__attribute__((used))` can be applied to the function via the
`LLVM_DUMP_METHOD` annotation to have the same effect.
2023-01-03 10:04:22 -06:00
Jeff Noyle 20bb3d0228
PIX: Modify root sigs in place (plus fix root sig memory leak) (#4876)
PIX is unique in that it needs to deserialize, modify and then reserialize root sigs. The focus of this checkin is adding such modifications to PixPassHelpers.cpp. (This closes a gap in PIX support: PIX can now support shaders that use dxil-defined and attribute-style root signatures.)

But this required some work outside of the purely PIX-focused areas. Deserialized root sigs are described by a C-like structure with embedded arrays that are new/delete-ed by routines in DxilRootSignature.cpp. Since modifying these structs requires more new/delete calls, I chose to add a new entry point in DxilRootSignature.cpp to do the bare minimum that PIX needs: extend root params by one descriptor. This approach keeps all those raw new/deletes in one file.

I found a leak in DxilRootSignatureSerialzier.cpp, which I fixed. There appear to be no unit tests that exercise this path. I welcome feedback on adding one.

There were other leaks in class CVersionedRootSignatureDeserializer, but this class is unused so I deleted it.

Oh, and there are bazillions of commits because I was cherry-picking from a recent change (#4845) as it eveolved, since I needed that change and this to test PIX.
2022-12-15 16:36:09 -08:00
Chris B df4ab75c51
[NFC] Address some low hanging fruit UBSan failures (#4833)
* Address some low hanging fruit UBSan failures

Undefined Behavior Sanitizer causes hard failures on runtime conditions that exhibit undefined behavior as defined by C and C++. These issues may not cause immediately identifiable software errors, but the code behavior is dependent on the compiler and runtime implementation. As a result they may become difficult to diagnose or detect errors in the future if the compiler or runtime changes.

This change addresses occurrences of the following undefined behaviors.

* Performing arithmetic operations on null pointers.
* Calling memcpy with a source or destination pointer that is null.
* Calling memset with a destination pointer that is null.
* Assigning an enum a value which is not a valid enum for that enum.
* Reading from unaligned pointers.

After this change, there are 23 remaining undefined behavior failures in the current DXC tests which are less trivial to resolve.
2022-12-10 11:42:25 -06:00
Nathan Gauër d6eb722516
build: fix include in header files. (#4652)
Building DXC with another build system revealed that some includes
were dependent on headers only available by chance. Adding missing
headers.

Signed-off-by: Nathan Gauër <brioche@google.com>

Signed-off-by: Nathan Gauër <brioche@google.com>
2022-09-15 16:00:29 +02:00
Tex Riddell 58f0ee2637
Strip Byte Order Markers (BOMs) and fix some related issues (#3880)
* Stop creating binary blobs with UTF-8 encoding

* Strip BOM and fix some related issues

- detect and strip BOM only when interpreting as text:
  - DxcCreateBlob: only when encoding is known and not CP_ACP
  - DxcGetBlobAsUtf[8|16]: when encoding not known or CP_ACP
- strncmp in BOM detection would misfire (should have been memcmp)
- ambiguous BOM case not handled/noted
- empty blob case fixes (handle null-term empty, don't leak)

Note, there are still problems in the unicode handling:
- No actual support for UTF-32 or big endian input encodings.
- For Linux: "UTF-16" isn't, and bad assumptions around "wide" strings.

* Add defines for CP_UTF*; improve error for unsupported utf conversions
2021-07-15 16:41:30 -07:00
Xiang Li bd38504d5e
Add -dumprs to dxa. (#3703) 2021-04-21 15:31:44 -07:00
Tex Riddell c3fa785435
Remove assert.h include from DxilPipelineStateValidation.h (#3129)
Also:
- fixed size_t to uint32_t error when building with other tools.
- removed DxilPipelineStateValidation.h where unused.
2020-09-16 23:15:08 -07:00
Zino 8372eab158
Missing import causing error on compilation (#2934)
Replaced <iostream> to <ios> in files using std::hex
2020-06-02 22:59:45 -06:00
Greg Roth 5515536594
Add iostream header to files using hex (#2897)
Possibly due to a visual studio update, building with vs2019 started
causing build failures due to using std::hex without the necessary
iostream include. This adds that include to the two files that need it.
2020-05-20 21:32:51 -07:00
Tex Riddell f6ff322db3
Add mesh shader support to RootSignature parsing/validation and fix PSV (#2363)
* Add mesh shader support to RootSignature parsing/validation
* Fix PSV so MS output topology doesn't overlap SigInputVectors
* fix PSV version code to use latest when validation disabled
2019-07-24 16:39:34 -07:00
Tristan Labelle d56f6eb93f
Fix allocator issues for dxc blob allocations (#2130)
DxcCreateBlobOnHeapCopy allocated using the COM allocator and freed using the default thread allocator, leading to crashes.

But more generally, some DxcCreateBlob functions would take ownership of the passed-in buffer without also having the caller explicitly specify what IMalloc to use for deallocation, which is an error-prone pattern, so I reworked these methods a bit.

This also lead me to find some memory leaks and general memory mismanagement in the the rewriter.
2019-04-18 15:04:06 -07:00
Tex Riddell 64bec9de53
Add DxilContainerReader and refactor PSV/RDAT into DxilContainer lib (#1642) 2018-10-29 17:54:05 -07:00
Xiang Li 16a5f94ab2
Move DxilRootSignature to its own directory. (#1609)
* Move DxilRootSignature to its own directory.
* Move DxilContainer into its own directory.
* Move DxilLoadMetadata into DxilUtil.
2018-10-17 18:46:43 -07:00